Title: Shell configuration files
Author: Sandro Tosi
Last modified: 2005-09-19
There are many files that cooperate to setup the shell environment,
and in general the environment in which applications will run.
We can subdivide those files in two categories: global and
user-specific. The first group contains generic configurations for
every user on the machine, the latter group contains the files that
modify the environment following the user's own configurations.
Some of the following files are about bash, since this is the shell I
use almost always, and the most widespread one.
Taken from man bash, we define
A login shell is one whose first character of argument zero is
a -, or one started with the --login option.
An interactive shell is one started without non-option
arguments and without the -c option whose standard input and
error are both connected to terminals (as determined by
isatty(3)), or one started with the -i option. PS1 is set and
$- includes i if bash is interactive, allowing a shell script
or a startup file to test this state.
Global configuration files
These files are machine-wide: every user's session will use them (or a
subset of them)
It's always read, even from graphical login manager, as
It's the right place for really important things, as language
System-wide .profile for all the user in the system that uses
Bourne compatible shells.
It is read from bash login shells, so not from graphical login
manager, as xdm/gdm/kdm. Note that every login shell configuration
file won't be read from graphical login manager since they do not
invoke any shell (this remains true even for some of the following
If you want X to load these configuration, try to modify
``/etc/X11/Xsession.d/99xfree86-common_start'' files changing
``exec $STARTUP'' into ``exec -l $SHELL -c "$STARTUP"'': X will be
loaded from a login shell, hence loading all configurations.
If you need to modify the PATH machine-wide, this is the right
System-wide .bashrc file for interactive bash shells. It contains
general bash configurations.
This is a good place to put your ``alias''es for all the users.
Configuration file for programmable completion; it will enable some
programmable completion functions to complete names no more only
for files (e.g., apt-get install <package>, package is double-tab
Those are some other configurations files found on my Debian, in
this case, for csh and tcsh shells.
It's the list of available login shells.
The directory contains the default user's bash configuration file:
they are copied into the user's home at user creation.
User specific files
These files are relative to the current user and they reside into the
user's $HOME. They modify the global environment with user's
Bash configuration file read for login shells. This is the first
user configuration file read.
If you need to modify the PATH only for this user, this is the
It's usual to include the following lines into this files
if [ -f ~/.bashrc ]; then
so that configurations done into ~/.bashrc are available even in
Configuration files read if ~/.bash_profile does not exists, as
It contains configuration loaded at login time.
List of commands to be executed at logout; it's only read from
Configuration file used for login shells; this file is only read if
~/.bash_profile and ~/.bash_login do not exist.
Read for interactive, non-login shells. It's the user bash
This is a good place to put your ``alias''es; if you choose to
write your ``alias''es into ~/.aliases, then add the following
if [ -f ~/.aliases ]; then
so that they will be loaded.
Hold the ``alias''es.
This file only exists if you opted to separate ``alias'' commands