Linux Training - Utilizing Shell Surroundings Variables

Linux Training - Utilizing Shell Surroundings Variables

The Linux Shell Environment and the Environment Variables

A Linux terminal or a terminal emulation window offers you access to the "bash shell setting" so you possibly can run Linux commands. And there are several "surroundings variables" which you could work with when utilizing Linux scripts, programs, and instructions, and to view system information.

You run the env (environment) command with none options to see the surroundings in your current user.

Run this Linux command now to see your current environment variable settings.

Linux Commands Training Tips: The Linux System Administration ideas and instructions covered here apply to ALL other Linux distributions, together with: Debian, Ubuntu, Slackware, SUSE, openSUSE, red hat on demand training Hat, Fedora, Edubuntu - and Kubuntu.

Bash Shell Surroundings Variable Examples

Listed below are some examples of widespread Linux environment variables.


This variable holds the name of the current Linux shell, which is mostly the "bash" shell.


Accommodates the name of the at present logged in user.


Holds the complete directory path to the current consumer's house directory.

For instance, should you're working as a non-root consumer, the trail might be /house/consumername, where consumername will be the name you logged in with. For those who logged in as bhatch, then the trail will likely be /dwelling/bhatch.

As one other example, should you're working as the basis person, then the trail will merely be /root.


Used to contain the settings for displaying the present Linux command line prompt.

For example, you should utilize this variable to specify how the prompt appears, similar to whether to show the present directory and the character that appears on the far proper of the prompt.


Shows the currently logged in user name.

Viewing Environmet Variables with the Linux echo Command

You'll be able to run the echo command and prefix a variable with a $ (dollar sign) to see the contents of a variable.

Run the echo command under to see your present user name.

$ echo $USER

Press the up arrow key to repeat the final command and press backhouse to remove the variable and substitute it with the variable that shows the path to the home directory for the current user.

Now do the identical as above with the other atmosphere variables described above.