-->
Previous Table of Contents Next


The command used to set and display these control-key parameters is stty, which stands for set teletype. In the “old days,” a teletype terminal was the only terminal available; a lot of UNIX terminology is left over from this era. For example, your terminal is defined as a tty device with a name such as tty14. To display all your present settings, enter stty -a from the command line. If you use this command, you see something like this:


speed 38400 baud; rows 25; columns 80; line = 0;

intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;

eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;

lnext = ^V; flush = ^O; min = 1; time = 0;

-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts

-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon

ixoff

-iuclc -ixany -imaxbel

opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0

ff0

isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt

echoctl echoke

Notice that on this system, the interrupt key (intr) is defined as <Ctrl-c> (shown as ^C), and the kill key is <Ctrl-u>. Although you can set all the settings listed here, as a matter of practicality, users usually only reset the interrupt and kill keys. For example, if you want to change the kill key from ^U to ^C, enter the following:


stty kill ‘^C’


NOTE:  If your terminal is behaving strangely, reset it to a “most reasonable” setting by giving the command stty sane.


TIP:  If you want a certain setting to take effect every time you log in, place the command in your .profile file (located in your home directory) if you’re running the bash, Bourne, or Korn shell. For the C shell, place the command in your .login file.

Setting the Shell Environment

Part of the process of logging in—that is, of creating a Linux session—is the creation of your environment. All Linux processes (as running programs are called) have their own environment separate and distinct from the program itself. It could be said that a program runs from within an environment. The Linux environment, called the shell environment, consists of a number of variables and their values. These variables and values allow a running program, such as a shell, to determine what the environment looks like.

Environment refers to things such as the shell that you use, your home directory, and what type of terminal you’re using. Many of these variables are defined during the login process and either can’t or shouldn’t be changed. You can add or change as many variables as you like as long as a variable hasn’t been marked “read-only.”

Variables are set in the environment in the form VARIABLE=value. The meaning of VARIABLE can be set to anything you like. However, many variables have predefined meanings to many standard Linux programs. For example, the TERM variable is defined as being the name of your terminal type, as specified in one of the standard Linux terminal databases. Digital Equipment Corporation for years made a popular terminal named the VT-100. The characteristics of this terminal have been copied by many other manufacturers and often emulated in software for personal computers. The name of such a terminal type is vt100; it’s represented in the environment as TERM=vt100.

Many other predefined variables exist in your environment. If you use the C shell, you can list these variables with the printenv command; with the Bourne or Korn shell, use the set command. Table 18.2 lists the most common environment variables and their uses. The Variable column shows what you type at the command line.


NOTE:  Some environment and system variables can be changed, and some can’t be changed.
Table 18.2 Common Bourne Shell Environment Variables

Variable Description

HOME=/home/login HOME sets your home directory, which is the location that you start out from. Replace login with your login ID. For example, if your login ID is jack, HOME is defined as /home/jack.
LOGNAME=login LOGNAME is automatically set the same as your login ID.
PATH=path The path option represents the list of directories that the shell looks through for commands. For example, you can set the path like this: PATH=/usr:/bin:/usr/local/bin.
PS1=prompt PS1 is the primary shell prompt that defines what your prompt looks like. If you don’t set it to anything specific, your prompt is the dollar sign ($). If you prefer, you can set it to something more creative. For example, PS1=“Enter Command >” displays Enter Command > as your command-line prompt.
PWD=directory PWD is automatically set for you. It defines where you are in the file system. For example, if you checked PWD (by entering echo $PWD at the command line) and Linux displays /usr/bin, you’re in the /usr/bin directory. The pwd command also displays the current directory.
SHELL=shell SHELL identifies the location of the program that serves as your shell. For example, you can set SHELL in your .profile or .login file as SHELL=/bin/ksh to make the Korn shell your login shell.
TERM=termtype Sets the name of your terminal type, as specified by the terminal database. For example, you can set TERM in your .profile or .login file as TERM=vt100.


NOTE:  If you want an environment variable defined every time you log in, place the definition in your .profile file (located in your home directory) if you’re running the bash or Bourne shell. For the C shell, place the definition in your .login file.

Perhaps the single most important variable in your environment is the PATH variable.


NOTE:  DOS users should be familiar with the PATH variable. It performs the same function under both DOS and Linux.


Previous Table of Contents Next