Shell variables are important for the smooth running of any Linux system.

Knowledge of shell variables is important for your daily use or administration of Linux systems.

There are different types of shells or command-line interpreters on Linux, all of which use variables extensively.

linux neofetch showing debian system

It is a system-wide environment variable and comprises a colon-separated list of directories.

Each directory is searched in turn for an executable file with the same name as the command you entered.

Why is this so important?

the path environment variable on a linux system

Many programs use the HOME variable to store configuration files or other data in the user’s home directory.

you could view the current value of the HOME variable by running theecho $HOMEcommand.

USER

The USER variable specifies the username of the currently logged-in user.

hostname on a linux system

you’re free to also use the variable for running certain generic commands.

The C shell (csh), Z shell (Zsh), fish, etc.

The SHELL variable specifies the path to the user’s default shell.

It is set automatically when you enter.

you could view the current value of the SHELL variable by running theecho $SHELL.

you’ve got the option to changeyour default shell using the chsh command.

PWD

Yet another important environment variable on Linux, PWD stores your current working directory.

The value of the variable is similar to the one you get when you initiate the pwd command.

HOSTNAME

A hostname or equipment name is a unique name used to identify your gear on a connection.

The HOSTNAME variable is an environment variable that simply specifies the hostname of the system.

There are several ways in which youcan change the hostname on Linux.

you’re free to also define your own shell variables by using the export command.