[Glastonbury] Shell RC file

Sean Miller sean at seanmiller.net
Mon Oct 13 07:51:55 BST 2003


It occurs to me that in answering the question neither myself or Andy
actually explained what an "rc" file does.

Linux/Unix shells have three major files that are processed when a user
logs in, or opens a new shell... for those who do not know ~ is a
character that represents "my home directory" (eg. /home/seanmiller) and
means the login directory as specified in /etc/passwd

bsh derivatives (ksh, bash, sh etc.)
------------------------------------

/etc/profile -- global options for all users. Here you can set up things
like standard paths, environment variables that you want *all* users to
inherit.

~/.profile -- same as above, but just for the one user. Allows you to
tweak your settings.

~/.kshrc (or .shrc or .bashrc) -- this one runs every time you initiate a
shell.... whilst the .profile runs once when you log in, the .xxxrc file
runs every time you spawn a session (eg. opening a new terminal window)...
I am trying to think of examples where this would be more appropriate than
.profile, but it's early in the morning and I am struggling... Andy?

csh
---

In csh (c-shell) the files do the same as above but are named...

/etc/login
~/.login
~/.cshrc

Syntax between csh and bourne shell derivatives are also different...
whilst in bourne etc. you'll set environment variables as "x=1" in csh it
will be "setenv x 1"

...but I really don't want to get *too* involved in differences within
shells, as most will be using something like bash or ksh in a Linux
environment.

One other file that you might like to play with is

~/.exrc -- this holds your default settings for "vi" and can be quite
useful... for example, you can put "set ic" in here and then the editor
will default to non case-sensitive searching. There are many other 'vi'
options.

Book recommendation would be "Linux in a Nutshell" by O'Reilly...
fantastic reference for all these various aspects (mine got stolen! so I
am reference-less, hence my general air of being disorganised ;-))

Sean



More information about the Glastonbury mailing list