Course: Linux Administration Bootcamp

Environment Variable

This article will illustrate the environment variables. Environment dynamic named value that is stored in the system and gets used by the application in shell or subshell. The variable name should be capitalized.

Two types of environment variables are available, such as:

  • Global variable: You will get variables in the whole of your system
  • Local variable: It will have some limited scope

To create, display, and use environment variables multiple commands are available. In the below-given table, some commands are provided with description:

Command Description
$ VARIABLE-NAME=‘any-value’ Create a local variable
$ unset Unset the created variable
$ export VARIABLE-NAME=‘any-value’ Create global variable
$ echo $PATH Show the path
$ echo $USER Show the system user
$ printenv <particular-variable>

 

Show the particular system user
$ printenv Display the list of an environment variables in the system

We have demonstrated the environment variables, their types, and some commands to create and display the environment variable. To execute commands practically, check out the attached video.

About the author

Talha Saif Malik

Talha is a contributor at Linux Hint with a vision to bring value and do useful things for the world. He loves to read, write and speak about Linux, Data, Computers and Technology.