Next | Prev | Up | Top | Contents | Index

Configurable Shell Environment Variables

Every shell uses a series of variables that hold information about the shell and about the login account from which it originated. These variables provide information to other processes as well as to the shell itself.

Collectively, these environment variables make up what is called the shell's environment. The basic concepts of environment variables and an environment are the same for all types of IRIX shells, although the exact method of creating and manipulating the environment variables differs.

A basic set of environment variables includes where in the IRIX file system to search for commands (PATH), the location of the home directory of the user's account (HOME), the present working directory (PWD), the name of the terminfo description used to communicate with the user's display screen or terminal (TERM), and some other variables.

When a process (shell) begins, the exec(2) system call passes it an array of strings, called the environment.

Since login is a process, the array of environment strings is made available to it. To look at your current shell environment, use the printenv command. A typical C shell environment might look something like this:

LOGNAME=trixie 
PWD=/usr/people/trixie 
HOME=/usr/people/trixie 
PATH=.:/usr/people/trixie/bin:/usr/bsd:/bin:/etc:/usr/sbin: 
/usr/bin: /usr/local/bin: 
SHELL=/bin/csh 
MAIL=/var/mail/trixie 
TERM=iris-ansi 
PAGER=more 
TZ=EST5EDT 
EDITOR=emacs 
DISPLAY=myhost:0 
VISUAL=vi 
For C shell users, these variables are set in either the /etc/cshrc, .cshrc, or .login startup files. For Korn and Bourne shell users, these variables are set in either the /etc/profile or .profile startup files.

The default environment variables that are assigned for C shell users, if no others are set in any of the startup files, are:

Other processes use this information. For example, user trixie's terminal is defined as an iris-ansi (TERM=iris-ansi). When the user invokes the default visual editor vi(1), vi checks this environment variable, then looks up the characteristics of an iris-ansi terminal.

New variables can be defined and the values of existing variables can be changed at any time with the setenv command (C shell only). For example, to change the PAGER variable under C shell, enter:

setenv PAGER pg

This sets the value of the PAGER environment variable to the command pg(1). The PAGER variable is used by mail(1).

Bourne and Korn shell users set environment variables like this:

$ PAGER=pg ; export PAGER

Environment variables can be set on the command line, or in either of the shell startup files /etc/profile or $HOME/.profile.


Next | Prev | Up | Top | Contents | Index