|
Contact me sending an e-mail (antispam defense activated) |
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.
Preliminary informations
=======================
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)
o /etc/environment
It's always read, even from graphical login manager, as
xdm/gdm/kdm.
It's the right place for really important things, as language
configuration
o /etc/profile
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
configuration files).
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
place.
o /etc/bash.bashrc
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.
o /etc/bash_completion
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
completed).
o complete.tcsh
csh.cshrc
csh.login
csh.logout
Those are some other configurations files found on my Debian, in
this case, for csh and tcsh shells.
o /etc/shells
It's the list of available login shells.
o /etc/skel/*
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
configurations.
o ~/.bash_profile
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
right place.
It's usual to include the following lines into this files
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
so that configurations done into ~/.bashrc are available even in
login shell.
o ~/.bash_login
Configuration files read if ~/.bash_profile does not exists, as
second choose.
It contains configuration loaded at login time.
o ~/.bash_logout
List of commands to be executed at logout; it's only read from
login shells.
o ~/.profile
Configuration file used for login shells; this file is only read if
~/.bash_profile and ~/.bash_login do not exist.
o ~/.bashrc
Read for interactive, non-login shells. It's the user bash
configuration file.
This is a good place to put your ``alias''es; if you choose to
write your ``alias''es into ~/.aliases, then add the following
lines
if [ -f ~/.aliases ]; then
source ~/.aliases
fi
so that they will be loaded.
o ~/.aliases
Hold the ``alias''es.
This file only exists if you opted to separate ``alias'' commands
from ~/.bashrc.
|