The environment variables are dynamic values that are stored within a system and used by applications launched in shells or sub-shells.
To Show all environment variable:
env
Some standard environment variables are as follows:
This variable contains a list of directories in which our system looks for files. It separates directories by a (:) colon.
This variable holds the username.
This variable holds the default path to the user's home directory.
This variable contains the path to the specified editor.
This variable contains the path to the user's unique id.
This variable contains the path to the default terminal emulator.
This variable contains the path to the default shell that is being used by the user.
This variable displays all the environment variable.
There are multiple commands in Linux that allow us to set and create the environment variable.
Use the export command to set a new environment variable.
To create a new variable, use the export command followed by a variable name and its value.
Syntax:
export NAME=VALUE
To create a new variable say new_variable, execute the command as follows:
export my_env_variable=10
The echo command is used to display the variable:
echo $my_env_variable
By removing an environment variable we can remove all existing component of particular variable.
To remove an environment variable, execute the unset command followed by variable name:
unset my_env_variable
Then echo removed variable and you will see empty return