## 3.7. Customizing Your Account

As we saw earlier, your home directory may have a hidden file called .profile. If it doesn't, there'll probably be one or more files named .login, .cshrc, .tcshrc, .bashrc, .bash_profile, or .bash_login. These files are shell setup files, and are the key to customizing your account. Shell setup files contain commands that are automatically executed when a new shell starts--especially when you log in.

Let's take a look at these files. Go to your home directory, then use less to display the file. Your .profile might look something like this:

>     PATH='/bin:/usr/bin:/usr/local/bin:'
>     LESS='eMq'
>     export PATH LESS
>     /usr/games/fortune
>     date
>     umask 002

A .login file could look like this:

>     set path = (/bin /usr/bin /usr/local/bin .)
>     setenv LESS 'eMq'
>     /usr/games/fortune
>     date
>     umask 002

As you can see, these sample setup files contain commands to print a "fortune" and the date--just what happened earlier when we logged in! (/usr/games/fortune is a useless but entertaining program that prints a randomly selected saying from its collection. fortune isn't available on all systems.)

But what are these other commands?

- The line with `PATH=` or `set path =` tells the shell which directories to search for Unix programs. This saves you the trouble of typing the complete pathname for each program you run. (Notice that /usr/games isn't part of the path, so we had to use the absolute pathname to get our daily dose of wisdom from the fortune program.) The `export PATH` is needed in the .profile, but not in .login.[12]

  > [12] Some shells that read the .profile let you set a variable's value on the same line as the export command, but not all do. Our two-step method for setting PATH works in all cases.

- The line with `LESS=` or `setenv LESS` tells the less program which options you want to set every time you use it. This saves you the trouble of typing the options on every less command line. The `export LESS` line is needed in the .profile, but not in .login.

- The umask command sets the default file permissions assigned to all files you create. Briefly, a value of 022 sets the permissions `rw-r--r--` (read-write by owner, but read-only by everyone else), and 002 produces `rw-rw-r--` (read-write by owner and group, but read-only by everyone else). If this file is a program or a directory, both umask settings also give execute (`x`) permission to all users. For more information, see one of the sources in Section 8.1 of Chapter 8.

You can change these files with a text editor, such as pico -w (see Section 4.3.2 in Chapter 4). Don't use a word processor that breaks long lines or puts special nontext codes into the file. Any changes you make to those files will take effect the next time you log in (or, in some cases, when you start a new shell--such as opening a new terminal window in your window system). Unfortunately, it's not always easy to know which shell setup file you should change.[13] And an editing mistake in your shell setup file can keep you from logging in to your account! We suggest that beginners get help from experienced users--and not make changes to these files at all if you're about to do some critical work with your account, unless there's some reason you have to make the changes immediately.

> [13] Some files are read by login shells, and others by nonlogin shells. Some are read by subshells; others aren't. Some terminal windows open login shells; others don't.

You can execute any of these programs from the command line, as well. In this case, the changes are in effect only until you close that window or log out. If your shell prompt has a `$` character in it, you'll probably use the syntax shown earlier in the .profile; if your shell prompt has a `%` or `>` instead, the syntax in the .login is probably right.

For example, to change the default options for less so it will clear the terminal screen before it shows each new page of text, you'll want to add the -c option to the LESS environment variable. The command you'd type at a shell prompt would look something like this:

>     $ LESS='eMqc'
>     $ export LESS

or like this:

>     % setenv LESS 'eMqc'

(If you don't want some of the less options we've shown, you could leave those letters out.) Unix has many other configuration commands to learn about; the sources listed in Section 8.1 of Chapter 8 can help.

Just as you can execute the setup commands from the command line, the converse is true: any command that you can execute from the command line can be executed automatically when you log in by placing it in your setup file. (Running interactive commands such as pine from your setup file isn't a good idea, though.)

Copyright © 2003 O'Reilly & Associates. All rights reserved.