BASH Start Up

Dot Config Files

When you run the Bash shell, there are a few start up files you can tune so Bash works more effectively. The files that directly impact your setup, environment and shell account are .bash_profile, .bashrc and .bash_logout. Understanding the login process helps.

When you login to Bash, a  system-wide file, /etc/profile is read first. Go have a look at the file. Next up Bash checks to see if you have .bash_profile in your home directory. If not it checks to see if you have .bash_login, if that file is missing too, Bash checks for .profile, the standard Bourne/Korn shell config file.

If .bash_profile is found, its contents are read and processed. The file is processed during login. It is read once. Place commands in .bash_profile you want to run once when you login. I include xmodmap command here, to remap Caps-Lock and Ctrl keys.

Next up Bash checks for .bashrc, which is processed during an interactively shell. Each time you launch an XTerm or fire up another console, this file is read and processed. You can include  aliases, prompt and color settings, fortune, and any custom commands. For example, I have a custom cd command to replace the stock item. When I cd into a directory I also get an ls of directory content and a pwd so I always know which dir I'm in as I navigate through the file system. Its tagged at the end of .bashrc file and looks like this:

# Modified cd command

cd () {
        builtin cd $1

I have a few aliases to help speed up command line work. If I vi a file to edit, it will launch emacs for me instead.

# ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
alias ld='ls -d'

# Other aliases
alias x='startx'
alias ftp='lftp'
alias ..='cd ..'
alias ...='cd ../ll'
alias .='pwd'
alias vi='emacs -nw'
alias emx='emacs -nw'

Finally we have .bash_logout. You can include commands to delete temporary files, delete emacs copies, run shell scripts, back up scripts, downloads, or anything else you may want carried out while you're not logged in.