CIS 3355 Lecture Notes - Lecture 11: Shell Script, Child Process, Environment Variable
Document Summary
Global environment variables: are visible from the shell session, and any child. Local environment variables: are only available in the shell that creates them. Linux sets several global environment variables when a user starts a bash session. The system environment variables use all capital letters to differentiate them from normal user environment variables. To view the global environment variables, use the printenv command: $ printenv. To display the value of an individual environment variable, use the echo command. When referencing an environment variable, place a dollar sign before the environment variable name: Global environment variables are also available to child processes running under the current shell session: The set command displays all of the environment variables set for a specific process, including the global environment variables. Setting local environment variables: once you start a bash shell (or spawn a shell script), you can create local variables that are visible within your shell process.