Share your love
Learn Environment Variables in Linux in 2 Easy Steps
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 custom variables. You can see all of them by using the env command.
Now proceed to the following steps provided by the Orcacore website to Learn Environment Variables in Linux in Easy Steps.
Easily Learn Environment Variables in Linux
These are some common Environment Variables in Linux 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 echo 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
- HISTSIZE: The HISTSIZE variable contains the number of commands stored in the history file. If you want to see the value inside the variable you can use HISTSIZE.
echo $HISTSIZE
- 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 environment variables. Let’s how we can do it.
Create a new environment variable in Linux
Here we show you how to create a new environmental variable. Remember to use capital letters for your environment variable. We want to show it by using an example:
MYMOOD=Happy
Then, verify it with the echo command in your output you should see a happy message:
echo $MYMOOD
Happy
Here you create a new environmental variable named “MYMOOD”. In this way, you can create thousands of environmental variables.
Conclusion
As you saw, 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. Also, you can create your variables simply as we mentioned above.
Hope you enjoy this article about environment variables in Linux and stay tuned for more articles.
Also, you may like to read the following articles:
Set and Unset Environment Variables in Linux with Examples