## 3.20. RC Files

One way to set defaults for your applications is with environment variables (Section 35.3) that the applications might read. This can get messy, though, if your environment has tens or hundreds of variables in it. A lot of applications have a different way to choose defaults: setup files, similar to shell setup files (Section 3.3). Most of these filenames end with rc, so they're often called RC files.[12] Today's more-complex applications also use their own setup subdirectories. Almost all of these files and directories are hidden (Section 8.9) in your home directory; you'll need ls -A to see them.

> [12]Don't ask me why. It's one of those acronyms, like spool (Section 45.2), that's open to interpretation, though one theory is that it is derived from "runcom files," (possibly short for "run commands") on the Compatible Time-Sharing System, c.1962-63 (source: The Jargon File).

This article describes some of the most common setup files. For a more complete list, check your application's manpage:

.emacs
  For the Emacs editor. See Section 19.3.
.exrc
  For the vi (actually, ex) editor. See Section 17.5.
.inputrc
  For the GNU Readline library and applications that use it, such as the bash shell.
.mailrc
  For the mail (Section 1.21) program and others like it. This can be handy if you use mail from the command line to send quick messages. For example:

  >     # If I send mail to "bookquestions", send it to myself too:
  >     alias bookquestions bookquestions@oreilly.com, jerry
  >     # When I send a message, prompt me for "cc:" addresses:
  >     set askcc

.mh_profile
  For the MH email system.
.netrc
  A listing of hostnames, accounts -- and possibly passwords -- used for connecting to remote hosts with ftp and some other programs. Should have file access mode (Section 50.2) 600 or 400 for security, but this may not be enough protection for passwords! Best used for Anonymous ftp.
.newsrc
  For news readers (Section 1.21). (Some newer news readers have more complex files.) A list of newsgroups in the order you want to see them. For example:

  >     comp.security.announce: 1-118
  >     news.announce.important: 1
  >     comp.org.usenix: 1-1745
  >     comp.sys.palmtops! 1-55069,55071
  >        ...

  A newsgroup name ending with a colon (:) means you want to read that newsgroup; an exclamation point (`!`) means you don't. After each name is a list of the article numbers you've read in that newsgroup; a range like `1-55069` means you've read all articles between number 1 and number 55069.

.rhosts
  A list of remote hostnames that are allowed to access your local machine with clients like rsh and rlogin (Section 1.21). Remote usernames are assumed the same as your local username unless the remote username is listed after the hostname. This file can be a security hole; make its file access mode (Section 50.2) 600 or 400. We suggest you only use it if your system or network administrator approves. For example:

  >     rodan             Allow a user with same username from host rodan
  >     foo.bar.com joe   Allow username joe from host foo.bar.com

.Xauthority
  For xauth, a program that handles authorization information used in connecting to the X Window System server.
.Xdefaults
  A resource file (Section 6.5) for the X Window System. Sometimes also called .xrdb.
.xinitrc
  A shell script (Section 35.2) that runs as you log in to an X Window System session using xinit. (Also see .xsession, later in this list.)

All commands except the last typically end with an ampersand (`&`), which makes those clients run in the background. The last command becomes the controlling process; when that process exits (for instance, you use the window manager's "quit" command), the window system shuts down. For example:

`$Id` Section 39.5, `exec >` Section 36.5, `-v` Section 35.25, `uname` `-n` Section 2.5 , `${..:=..}` Section 36.7, `export` Section 35.3, `xrdb` Section 6.8, `sh` `-c` Section 24.21, `exec` Section 36.5

>     #! /bin/sh
>     # $Id: ch03_20.htm,v 1.3 2002/11/05 20:18:59 ellie Exp ellie $
>     # Usage: .xinitrc [DISPLAY]

>     wm=fvwm2    # window manager

>     # Put all output into log that you can watch from a window (tail -f):
>     mv -f $HOME/tmp/startx.log $HOME/tmp/,startx.log
>     exec > $HOME/tmp/startx.log 2>&1
>     set -v

>     # Set DISPLAY from $1 if the X server isn't on same host as client:
>     if [ $# -gt 0 ]
>     then
>         if [ $# -ne 1 ]
>         then
>             echo "Usage: .xintirc [DISPLAY]" 1>&2
>             exit 1
>         else
>             DISPLAY=$1
>         fi
>     else
>         host=`uname -n`
>         DISPLAY=${DISPLAY:=$host:0.0}
>     fi
>     export DISPLAY
>     xrdb -load $HOME/.xrdb

>     #
>     # Clients
>     #
>     xterm -C -geometry 80x9+0+0 -sl 2000 &
>     oclock -geometry -1+1 &
>     xterm -title "SETI console" -bg blue -fg white -geometry 80x9+768+1 -e \
>         sh -c 'cd /var/cache/seti && exec ./setiathome -nice 5 -verbose' &
>     # Don't use -e because Mozilla crashes; start by hand from prompt:
>     xterm -title "Mozilla console" -bg orange -geometry 80x9-0+1 &
>     xterm -geometry 80x74+329-81 &

>     #
>     # Start window manager
>     #
>     exec $wm

.xsession
  An executable file (generally a shell script (Section 35.2), but it can be any executable) that runs as you log into an X Window System session using xdm. See .xinitrc, earlier in this list.
/etc/rc*
  Last but not least, your system probably has a lot of setup files in its /etc directory. Look for subdirectory or filenames starting with rc. These are read when your system reboots or changes its runlevel (for example, from single-user mode to multiuser mode). These files are basically shell scripts (Section 35.2). If you know a little about shell programming, you can learn a lot about your system by looking around these files.

--JP and SJC

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