3.7. Customizing Your AccountAs 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?
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.
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. |
|