The syntax for setting an environment variable under UNIX/Linux depend on the shell that you are using.
The syntax for bash/sh shell is
export <variable name> = $<variable name>:<new value1>:<new value2> |
For tcsh/csh shell
set <variable name> = ($<variable name> <new value1> <new value2>) |
You can set the environment variable either from a terminal or add it directly to your .bashrc (for BASH/sh shell) or .cshrc (for tcsh/csh shell).
For example to add /usr/local/bin to your PATH under bash, open ~/.bashrc and enter
export PATH = $PATH:/usr/local/bin |
Or enter the following in a terminal to append to your .bashrc file
echo 'export PATH = $PATH:/usr/local/bin' >> ~/.bashrc |
If you are using tcsh/csh, open ~/.tcsh and enter
export PATH = ($PATH /usr/local/bin) |
Or enter the following in command line or terminal to append to your .tcsh file
echo 'set PATH = ($PATH /usr/local/bin)' >> ~/.cshrc |
To display path settings, enter in the terminal
echo $PATH |
To delete a environment variable, type in the terminal
unset <variable name> |