Linux Training - Using Shell Surroundings Variables

Linux Training - Using Shell Surroundings Variables

The Linux Shell Atmosphere and the Setting Variables

A Linux terminal or a terminal emulation window provides you access to the "bash shell atmosphere" so you'll be able to run Linux commands. And there are several "setting variables" that you may work with when using Linux scripts, programs, and instructions, and to view system information.

You run the env (setting) command with none options to see the surroundings for your present user.

Run this Linux command now to see your present atmosphere 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 certification malaysia Hat, Fedora, Edubuntu - and Kubuntu.

Bash Shell Setting Variable Examples

Listed below are some examples of frequent Linux atmosphere variables.

SHELL

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

USER

Contains the name of the at present logged in user.

HOME

Holds the total directory path to the current person's residence directory.

For instance, in the event you're working as a non-root user, the path will probably be /dwelling/username, the place username will be the name you logged in with. When you logged in as bhatch, then the trail shall be /dwelling/bhatch.

As another example, in the event you're working as the basis user, then the trail will merely be /root.

PS1

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

For instance, you can use this variable to specify how the immediate seems, comparable to whether or not to show the current directory and the character that seems at the far right of the prompt.

LOGNAME

Shows the at the moment logged in person name.

Viewing Environmet Variables with the Linux echo Command

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

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

$ echo $USER

Press the up arrow key to repeat the final command and press backhouse to take away the variable and substitute it with the variable that shows the trail to the house directory for the current user.

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