Setting Path Guidelines
Here are some guidelines for setting up efficient PATH variables:
If security is not a concern, put the current working directory (.) first in the path. However, including the current working directory in the path poses a security risk that you might want to avoid, especially for superuser.
Keep the search path as short as possible. The shell searches each directory in the path. If a command is not found, long searches can slow down system performance.
The search path is read from left to right, so you should put directories for commonly used commands at the beginning of the path.
Make sure directories are not duplicated in the path.
Avoid searching large directories, if possible. Put large directories at the end of the path.
Put local directories before NFS mounted directories to lessen the chance of "hanging" when the NFS server does not respond and to reduce unnecessary network traffic.
Examples--Setting a User's Default Path
The following examples show how to set a user's default path to include the home directory and other NFS mounted directories (the current working directory is specified first in the path). In a C-shell user initialization file, you would add the following:
set path=(. /usr/bin $HOME/bin /net/glrr/files1/bin) |
In a Bourne- or Korn-shell user initialization file, you would add the following:
PATH=.:/usr/bin:/$HOME/bin:/net/glrr/files1/bin export PATH |
Locale Variables
The LANG and LC environment variables specify the locale-specific conversions and conventions for the shell, like time zones, collation orders, and formats of dates, time, currency, and numbers. In addition, you can use the stty command in a user initialization file to set whether the system will support multibyte characters.
LANG sets all possible conversions and conventions for the given locale. If you have special needs, you can set various aspects of localization separately through these LC variables: LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_NUMERIC, LC_MONETARY, and LC_TIME.
The following table describes some of the values for the LANG and LC environment variables.
Table 4-21 Values for LANG and LC Variables
Value | Locale |
---|---|
de | German |
fr | French |
iso_8859_1 | English and European |
it | Italian |
japanese | Japanese |
korean | Korean |
sv | Swedish |
tchinese | Taiwanese |
Examples--Setting the Locale Using the LANG Variables
The following examples show how to set the locale using the LANG environment variables. In a C-shell user initialization file, you would add the following:
setenv LANG DE |
In a Bourne- or Korn-shell user initialization file, you would add the following:
LANG=DE; export LANG |
Default File Permissions (umask)
When you create a file or directory, the default file permissions assigned to the file or directory are controlled by the user mask. The user mask is set by the umask command in a user initialization file. You can display the current value of the user mask by typing umask and pressing Return.
The user mask can be set with a three-digit octal value. The first digit sets permissions for the user; the second sets permissions for group; the third sets permissions for other (also referred to as "world"). Note that if the first digit is zero, it is not displayed. For example, if umask is set to 022, 22 is displayed.
To determine the umask value you want to set, subtract the value of the permissions you want from 666 (for a file) or 777 (for a directory). The remainder is the value to use with the umask command. For example, suppose you want to change the default mode for files to 644 (rw-r--r--). The difference between 666 and 644 is 022, which is the value you would use as an argument to the umask command.
You can also determine the umask value you want to set by using the following table, which shows the file and directory permissions that are created for each of the octal values of umask.
Table 4-22 Permissions for umask Values
umask Octal Value | File Permissions | Directory Permissions |
---|---|---|
0 | rw- | rwx |
1 | rw- | rw- |
2 | r-- | r-x |
3 | r-- | r-- |
4 | -w- | -wx |
5 | -w- | -w- |
6 | --x | --x |
7 | --- (none) | --- (none) |
The following line in a user initialization file sets the default file permissions to rw-rw-rw-.
umask 000 |
Examples of User and Site Initialization Files
The following sections provide examples of user and site initialization files that you can use to start customizing your own initialization files. Many of the examples use system names and paths that you need to change for your particular site.
Example--.profile File
1 PATH=$PATH:$HOME/bin:/usr/local/bin:/usr/ccs/bin:. 2 MAIL=/var/mail/$LOGNAME 3 NNTPSERVER=server1 4 MANPATH=/usr/share/man:/usr/local/man 5 PRINTER=printer1 6 umask 022 7 export PATH MAIL NNTPSERVER MANPATH PRINTER |
Defines the user's shell search path.
Defines the path to the user's mail file.
Defines the user's Usenet news server.
Defines the user's search path for man pages.
Defines the user's default printer.
Sets the user's default file creation permissions.
Sets the listed environment variables.