DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Customizing your environment

A sample login script

Here is a simplified .profile file:

   # -- aliases; Korn shell only
   alias dir='ls -al'
   alias del='rm'
   alias mail='op email'
   # -- environment; Bourne and Korn shells
   PATH=/bin:/usr/bin:/usr/local/bin:$HOME/bin:
   set -o emacs # Korn shell history editing
   MAIL=/u/charlie/.mailbox
   PS1='$PWD>'
   PS2='$PWD>>'
   TERM=wy60
   export PATH MAIL PS1 PS2 TERM
   echo # prints a blank line
This file is run automatically when you log in, if your login shell is the Bourne or Korn shell. The first line of this file begins with a ``#'' character; this introduces a ``comment'', a line of text which the shell ignores. Comments are used to make shell scripts easier to understand.

The first section of this file contains a list of aliases. Aliases define synonyms for commands. For example, if you are used to the DOS environment, you will be familiar with the command dir to obtain a directory listing. To set up dir as an alias for the corresponding command (ls), the following line is executed:

alias dir='ls -al'

Once this command has been executed, every time you type dir the login shell will replace ``dir'' with ``ls -al''.


NOTE: This form of alias syntax is recognized by the Korn shell: the C shell uses a different syntax, and the Bourne shell does not provide aliases. (A Bourne shell startup file will therefore omit these lines.)

See ``How aliases are executed'' for a detailed explanation of aliases.

After alias expansion, a number of environment variables are set. These are then exported with the export command, so that they are available to subprocesses running under the current login shell. In general, variables set in the startup files are important to the smooth running of your login session. For example, note the reference to the variable PATH. This contains a list of directories, separated by colons.

When you type a command without specifying any directory, the shell looks for a file of that name among the directories in PATH (unless the command is built into the shell, in which case it is executed without a search). If it finds a file of that name it tries to execute it; otherwise, the command fails because the shell could not find the correct program to run. If you remove the PATH variable you will be unable to execute programs without specifying their full pathname. For example, you would have to type /bin/vi instead of just vi to run the editor.


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 22 April 2004