Environment Variables in Linux

In this article, we want to show you environment variables in Linux.

Environment Variables are simply a set of predefined names that have a specific value that allows the Linux command line to understand what they mean.
Some of these variables are present in Linux by default, but Linux users can also create their own custom variables. You can see all of them by using the env command.

what you read in this post?

Environment Variables in Linux

These are some common environment variables that we bring for you:

HOME
Home is an environmental variable that indicates the user’s home directory.
In the command line we can enter the following command:

echo $HOME

PATH
The path is a list of directories that are scanned when we run a command to find a program or script to find that program or script. Each directory in the PATH is separated from other directories using a: mark.

echo $PATH

PWD
It shows where am I at this time.

echo $PWD

USER
It gives me the name of the logged-in user.

echo $USER

If you want to see the value inside the variable you can use HISTSIZE.

echo $HISTSIZE

The HISTSIZE variable contains the number of commands stored in the history file.

SHELL
This variable indicates the path of the current user shell, such as bash or zsh.

echo $SHELL

EDITOR
This variable indicates the default file editor used. This editor is the same editor used when typing edit in your terminal.

echo $EDITOR

PPID
This variable shows the current ID process.

echo $PPID

Also, we said that users can create their own environment variables.

Create environmental variables on Linux

Here we show you how to create a new environmental variable.
Tip: use capital letters.
For example:

MYMOOD=Happy
echo $MYMOOD
Happy

Here you create a new environmental variable named “MYMOOD”. In this way, you can create thousands of environmental variables.

Conclusion

Hope you enjoy this article about environment variables in Linux and stay tuned for more articles on the orcacore website.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!