Environment Variables are dynamic values which affect the processes or programs on a computer.
Environment variables are case-sensitive and usually they are created in upper case.
Environment variables are case-sensitive and usually they are created in upper case.
Command | Description |
---|---|
echo $VARIABLE | To display value of a variable. |
printenv | Displays all or part of environment variables, |
env | Displays all exported environment variables. |
VARIABLE_NAME= variable_value | Create a new variable. |
set | Display the name and value of each shell variable. |
unset | Remove a variable. |
export Variable=value | To set value of an environment variable. |
System Variable | Meaning | To View Variable Value Type |
---|---|---|
BASH_VERSION | Holds the version of this instance of bash. | echo $BASH_VERSION |
HOSTNAME | The name of the your computer. | echo $HOSTNAME |
CDPATH | The search path for the cd command. | echo $CDPATH |
HISTFILE | The name of the file in which command history is saved. | echo $HISTFILE |
HISTFILESIZE | The maximum number of lines contained in the history file. | echo $HISTFILESIZE |
HISTSIZE | The number of commands to remember in the command history. The default value is 500. | echo $HISTSIZE |
USER | The username of the current user | echo $USER |
HOME | The home directory of the current user. | echo $HOME |
IFS | The Internal Field Separator that is used for word splitting after expansion and to split lines into words with the read builtin command. The default value is <space><tab><newline>. | echo $IFS |
LANG | Used to determine the locale category for any category not specifically selected with a variable starting with LC_. | echo $LANG |
PATH | The search path for commands. It is a colon-separated list of directories in which the shell looks for commands. | echo $PATH |
PS1 | Your prompt settings. | echo $PS1 |
TMOUT | The default timeout for the read builtin command. Also in an interactive shell, the value is interpreted as the number of seconds to wait for input after issuing the command. If not input provided it will logout user. | echo $TMOUT |
TERM | Your login terminal type. | echo $TERM; export TERM=vt100 |
SHELL | Path to login shell being used by the user. | echo $SHELL |
DISPLAY | Set X display name | echo $DISPLAY; export DISPLAY=:0.1 |
EDITOR | Path to the program which edits the content of files | export EDITOR=/usr/bin/vim |
UID | User's unique ID | echo $UID |