$title = "Unix variables"; $area = "Unix Support"; $metadata = "unix,variable,environment,shell,set,unset,editor,exinit,home,logname,mail,manpath,pager,path,lpdest,term,tz,user,cwd,status, printer"; $pfloc = ""; require '/usr/local/wwwdocs/ucs/fragments/header.phtml'; require '/usr/local/wwwdocs/ucs/fragments/header-bc.phtml'; ?>
Customising your Unix environment ( $filesize = filesize("/usr/local/wwwdocs/ucs/docs/pdf/117.pdf"); print ("
$filesize Bytes
"); ?>)Standard Unix variables are split into two categories, environment and shell variables. In broad terms, shell variables apply only to the current instance of the shell and are used to set short-term working conditions; environment variables have a farther reaching significance, and those set at login are valid for the duration of the session. By convention, environment variables have UPPER CASE and shell variable have lower case names.
Users may create their own variables in order to customise their environment but it is necessary to avoid clashes with the names of the standard variables.
Variables may be set in the .login or .cshrc initialisation files and may be subsequently referred to by prefixing their name with $, e.g. $EDITOR.
ENVIRONMENT variables are set using the setenv command, displayed using the printenv or env commands, and unset using the unsetenv command. Some commonly used environment variables are:
Name |
Description |
EDITOR |
the editor that will be used by other programs such as the mail program. |
EXINIT |
customisation options for the ex and vi text editors. |
HOME |
the path name of your home directory. |
LOGNAME |
your login name |
LPDEST |
default destination for print jobs submitted via lp. |
the location of your mailbox for incoming email. |
|
MANPATH |
the list of directories to search for manual pages |
PAGER |
Sets the pager that will be used by programs such as man to display man pages. |
Specifies the directories that the shell is to look through to find a command. These directories are searched in the order in which they appear. |
|
PRINTER |
default destination for print jobs submitted via lpr. |
SHELL |
your login shell. |
SYS_TYPE |
the type of system you are using, e.g. Sun, SGI |
TERM |
the terminal type for programs such as the editor and pager. |
TZ |
the time zone. |
USER |
your login name |
Shell variables are both set and displayed using the set command. They can be unset by using the unset command. Shell variables set automatically on ISS Unix systems are:
argv |
of significance to shell programmers |
cwd |
your current working directory |
home |
the path name of your home directory |
path |
the list of directories to search for programs |
prompt |
the text string used to prompt for interactive commands |
shell |
your login shell |
status |
a code indicating the degree of success of the previous command |
term |
the type of 'terminal' you are using |
In general, environment and shell variables that have the same name (apart from the case) are distinct and independent, except for possibly having the same initial values. There are, however, exceptions.
Each time the shell variables home, user and term are changed, the corresponding environment variables HOME, USER and TERM receive the same values. However, altering the environment variables has no effect on the corresponding shell variables.
path and PATH specify directories to search for commands and programs. Both variables always represent the same directory list, and altering either automatically causes the other to be changed.