Linux Environment Variables
Environment variables in the
bash shell help you in several
ways. Certain built-in variables
change the shell in ways that make
your life a little easier, and you
can define other variables to suit
your own purposes. Here are some
examples of built-in s hell
variables:
In UNIX/Linux systems,
to list environment variables:
env
In UNIX/Linux systems, add a
dollar sign ($) in front of each
variable name in all caps:
| echo $LOGNAME |
user name used for login |
| echo $USER |
user name (sudo) |
| echo $UID |
user name |
| echo $SHELL |
directory containing OS
shell executables |
| echo $PATH |
directories containing
executables, searched to find
applications when no absolute
path is specified on the
command line. |
| echo $LD_LIBRARY_PATH |
path to system and user
libraries |
| echo $MANPATH |
directory containing
manuals |
| echo $HOME |
directory of user's home
directory |
| echo $TZ |
time zone, such as
"US/Mountain" |
In UNIX systems, the colon (:).
In Windows systems, the semi-colon
(;) is used. So to list each path
in a separate line:
echo $PATH | tr ':' '\n'
Solaris systems have additional
ones, including:
| echo $BASH |
path to the shell on the
file system. |
| echo $HOSTNAME |
name of the current
system. |
| echo $PPID |
parent process ID |
| echo $WINDOWMANAGER |
name of the X11 window
manager |
| echo $COLUMNS |
The column width for the
terminal |
| echo $DISPLAY |
The display variable used
for X11 graphics. |
Creating Variables on Linux
To update an environment
variable that lives until the next
reboot:
#export PATH=”/usr/local/XXX/bin:$PATH”
#echo $PATH
Notice that colons are used to
separate path items.
To create an environment
variable that lives forever,
update your .bash_profile file:
XXXPATH=”/usr/local/XXX/bin”
export XXXPATH
For a list of environment
settings (arguments) for a process
with PID 23141 (on Solaris):
pargs -ae 23141
|