University Systems --> WAM --> Page Has Been Retired --> Common Variables In The Unix OS Shell -->

Common Variables In The Unix OS Shell

This is a list of some of the most commonly used variables. For more information, see the man pages for the shell that you are using.

Some terms used in this listing, such as wildcards, aliases, redirection, and jobs, are discussed in the section on UNIX shells.

cdpath
When you change to another directory, if it is not a full path name starting with /, the shell checks to see if the directory exists within the current directory, if it fails to find it there, it then checks the cdpath variable for a list of directories to search for the directory name, and if found changes directory to that directory.
cwd
The shell sets this to the full path name of the current directory when you change your directory. If you change directory through a link, that path name is relative to the link. That is, it is not the actual path, but the path you followed though the link.
echo
If this variable exists, the shell will echo the command and all arguments before executing the command. It echoes back the command and arguments in its final form, after variable, wild card, and alias expansion.
history
Sets the number of previously executed commands to remember. After the execution of every command, the command with its arguments in put on a list, after the list has reached the set number of commands, the older ones are discarded.
home
Set by the shell upon login, the home variable contains the full path name to your home directory. If changed, both the cd command and ~ will refer to the new path.
ignoreeof
If set, the shell will not exit when a ^D (control-D, or end of file) is encountered on the command line. Since ^D is used as an end of file, typing ^D in the shell normally exits the shell.
mail
The shell can be told to tell you when and where (which file) you have received mail. If set, the shell checks by default every ten minutes to see if you have mail, and if you do it will follow the last command's output with "You have new mail". To change the interval in seconds at which the shell checks the mail file, use a numeric value as the first (or only) argument when setting the mail variable. If you need to change the mail file that the shell looks at (generally, it will look at the default file mail is delivered to), or add another mail file for it to watch, specify it after the time interval or by itself when setting mail. Examples: To have the shell check mail every minute type set mail=60, to have the shell check the file joebob.mbox in your home directory, type set mail=joebob.mbox, and finally if you want to have it do both and check /var/spool/mail too, type set mail=(60 joebob.mbox /var/spool/mail). In the later example, when mail arrives the shell will report which file the new mail arrived in.
noclobber
If set, noclobber prevents files from being overwritten on redirection of output.
noglob
If set, noglob prevents wild card characters from being expanded.
nonomatch
If set, the shell will not complain if no files match a wild card expression. Normally, if no files match the expression, the shell will not execute the command, in the case of nonomatch, the command will be executed and given the wild card as the argument if it can't find matching files.
notify
If set, the shell will notify you exactly when a job completes, rather than displaying it before printing a prompt.
path
This is a list of directories the shell will search when it starts up. The shell will compile a list, called a hash table, of all the executable files found in the directories listed in the path variable. When you issue a command, the shell searches the table for the command, unless the command issued contain a path name (i.e. bin/command or /usr/local/bin/command). When the shell checks for the executable, it looks at the list in order that the entries were added, so if commands with the same name are encountered, the one found in the directory first in the path will be the one it executes.
prompt
Sets the string you see when the shell is ready for input. If you put a '!' in the string, the shell will replace it with the current numerical history number. Note: since this is a string value, you need to quote the whole string.
savehist
The number of previously executed commands to save in ~/.history when you exit the shell. This file is normally loaded when you start a new shell.
verbose
Causes commands to be echoed before execution, this is done after any history substitution of the command, (i.e. !! would print out the last command typed in, then it would be executed.
How do I:
How are we doing? Comments on this page?
Office of Information Technology
Office of Information Technology Help Desk Web Site University of Maryland Web Site Office of Information Technology Web Site