4.14. Startup Files
Configuration is a strong element of Unix. This probably stems from two traits commonly found in hackers: they want total control over their environment, and they strive to minimize the number of keystrokes and other hand movements they have to perform. So all the major utilities on Unixeditors, mailers, debuggers, X Window System clientsprovide files that let you override their default behaviors in a bewildering number of ways. Many of these files have names ending in rc, which means resource configuration.
Startup files are usually in your home directory. Their names begin with a period, which keeps the ls command from displaying them under normal circumstances. None of the files is required; all the affected programs are smart enough to use defaults when the file does not exist. But everyone finds it useful to have the startup files . Here are some common ones:
For the bash shell. The file is a shell script, which means it can contain commands and other programming constructs. Here's a very short startup file that might have been placed in your home directory by the tool that created your account:
PS1='\u$' # The prompt contains the user's login name. HISTSIZE=50 # Save 50 commands for when the user presses the up arrow. # All the directories to search for commands. PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11 # To prevent the user from accidentally ending a login session, # disable Ctrl-D as a way to exit. IGNOREEOF=1 stty erase "^H" # Make sure the backspace key erases.
For the bash shell. Another shell script. The difference between this script and .bashrc is that .bash_profile runs only when you log in. It was originally designed so that you could separate interactive shells from those run by background processors such as cron (discussed in Chapter 10). But it is not very useful on modern computers with the X Window System because when you open a new terminal window, only .bashrc runs. If you start up a window with the command xterm -ls, it will run .bash_profile too.
Like .bashrc, but for zsh.
Like .bash_profile, but for zsh.
For the C shell or tcsh. The file is a shell script using C shell constructs.
For the C shell or tcsh. The file is a shell script using C shell constructs. Like .bash_profile in the bash shell, this runs only when you log in. Here are some commands you might find in .cshrc or .login:
set prompt='$ ' # Simple $ for prompt. set history=50 # Save 50 commands for when the user presses the up arrow. # All the directories to search for commands. set path=(/usr/local/bin /usr/bin /bin /usr/bin/X11) # To prevent the user from accidentally ending a login session, # disable Ctrl-D as a way to exit. set ignoreeof stty erase "^H" # Make sure the backspace key erases.
For the Emacs editor. Consists of LISP functions. See "Tailoring Emacs" in Chapter 19.
For the vi editor (a visual editor that incorporates the older ex editor). Each line is an editor command. See "Extending vi" in Chapter 19.
For news readers. Contains a list of all newsgroups offered at the site.
For the X Window System. Consists of shell commands that run whenever you log in to an X session. See "Running X" in Chapter 16 for details on using this file.
This is actually a whole directory with configuration files for the K Desktop Environment (KDE). You will find a lot of files here, all starting with the name of the program they configure and ending in rc. Note that you should normally not need to edit these files manually; the respective programs all come with their own configuration dialogs. Depending on the KDE version, this path might start with .kde2 or .kde3.
Like the previous entry, a whole directory of configuration files , this time for the GNOME graphical desktop.