Setting Environment Variables
Environment variables are used to store information in a form that is accessible to commands within the shell and other applications that are spawned from the shell. You can obtain a list of all environment variables that have been set in a shell by using the following command:
bash-2.03$ set
BASH=/usr/local/bin/bash
BASH_VERSINFO=([0]="2" [1]="03" [2]="0" [3]="1"
[4]="release" [5]="i386-pc-solaris2.9")
BASH_VERSION='2.03.0(1)-release'
COLUMNS=80
DIRSTACK=()
DISPLAY=cassowary:0.0
EDITOR=/usr/bin/vi
ENV=/.kshrc
EUID=0
GROUPS=()
HELPPATH=/usr/openwin/lib/locale:/usr/openwin/lib/help
HISTFILE=/.sh_history
HISTfilesIZE=500
HISTSIZE=500
HOME=/
HOSTNAME=cassowary
HOSTTYPE=i386
IFS=' '
LANG=en_AU
LC_COLLATE=en_AU
LC_CTYPE=en_AU
LC_MESSAGES=C
LC_MONETARY=en_AU
LC_NUMERIC=en_AU
LC_TIME=en_AU
LD_LIBRARY_PATH=/usr/local/lib:/usr/openwin/lib:/usr/dt/lib
LINES=24
LOGNAME=root
MACHTYPE=i386-pc-solaris2.9
MAIL=/var/mail/root
MAILCHECK=60
MANPATH=/usr/dt/man:/usr/man:/usr/openwin/share/man
OPENWINHOME=/usr/openwin
OPTERR=1
OPTIND=1
OSTYPE=solaris2.9
PATH=/usr/sbin:/usr/bin:/bin:/usr/ucb:/usr/local/bin:/usr/ccs/bin
PIPESTATUS=([0]="1")
PPID=1584
PS1='\s-\v\$ '
PS2='>> '
PS4='+ '
PWD=/etc
SESSION_SVR=tango
SHELL=/bin/ksh
SHLVL=1
TERM=dtterm
TERMINAL_EMULATOR=dtterm
TZ=Australia/NSW
UID=0
USER=root
WINDOWID=58720265
Although this seems to be a lot of shell variables, the most significant ones include the following:
BASH | The path to the shell on the file system |
COLUMNS | The column’s width for the terminal |
DISPLAY | The display variable that is used for X11 graphics |
HOME | The default home directory for the user |
HOSTNAME | The hostname of the current system |
LD_LIBRARY_PATH | The path to system and user libraries |
LOGNAME | The username of the shell owner |
MANPATH | The path to the system manuals |
NNTPSERVER | The hostname of the NNTP server |
PATH | The path that is searched to find applications where no absolute path is specified on the command line |
PPID | The parent process ID |
TERM | The terminal type (usually VT100) |
UID | The user ID |
WINDOWMANAGER | The name of the X11 window manager |
The values of all shell variables can be set on the command line by using the export command. For example, if you wanted to set the terminal type to VT220, you would use this command:
$ TERM=vt220; export TERM