home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Running Linux, 4th Ed.Running Linux, 4th Ed.Search this book

4.15. 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 Unix — editors, mailers, debuggers, X Window System clients — provide 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:

.bashrc
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.
.bash_profile
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 like cron (discussed in Chapter 8). 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.

.cshrc
For the C shell or tcsh. The file is a shell script using C shell constructs.

.login
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.
.emacs
For the Emacs editor. Consists of LISP functions. See Section 11.6.1 in Chapter 11.

.exrc
For the vi editor (also known as ex). Each line is an editor command. See Section 11.1 in Chapter 11.

.newsrc
For news readers. Contains a list of all newsgroups offered at the site.

.Xdefaults
For programs using the X Window System. Each line specifies a resource (usually the name of a program and some property of that program) along with the value that resource should take. This file is described in Section 11.6.1 in Chapter 11.

.xinitrc
For the X Window System. Consists of shell commands that run whenever you log into an X session. See Section 11.1 in Chapter 11 for details on using this file.

.kde/share/config
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.

.gnome
Like the previous entry a whole directory of configuration files, this time for the GNOME graphical desktop.



Library Navigation Links

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