Do you ever wonder what is happening when you login to a BASH shell. Why "ll" command works only on your office machine?? This article will give you a breif outlook on bash startup files. When you login the first file that is checked in your home directory is "~.bash_profile".
~ means your home directory.  This file will decide what all files have to be read during startup or the pragrams/commands to run when you login to bash.  A sample ".bash_profile"


# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then . ~/.bashrc fi
# User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH unset USERNAME

Next file is "~.bashrc", which is also inside your home directory.  Remeber about "ll" ("ll" is actually an alias to "ls -l").  It is set in this file. A sample ".bashrc"

# .bashrc
# User specific aliases and functions
alias ll='ls -l' alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then /etc/bashrc fi

Please note alias must be set on this file only. Because this is the only file read when we open a terminal from "Gnome or KDE or any other desktop environment". Next one is "~.bash_logout" . As the file says, we can specify commands that has to be run during when logout. See a sample ".bash_logout"

# ~/.bash_logout clear

A small trick … want to delete history during log out . . . :) Add the following to .bash_logout

echo "" > ~.bash_history

Thanks

6 Responses to “Bash tips - Configuration files read when user login/logout BASH shell”

  1. leszek Says:

    A better method to prevent the logging of the history is to create a .bash_history directory:

    rm ~/.bash_history
    mkdir ~/.bash_history

  2. anil Says:

    Yeah … That is a good trick. Thanks

  3. Unix Mouth » Bash tips - Configuration files read when user login/logout BASH shell Says:

    […] read more | digg story […]

  4. goveAriggip Says:

    I gulped. His shallow pool included another pic, his vile waffle tinged up by two fingers.

  5. goveAriggip Says:

    This wouldn’t britney spears fake picture stable if she didn’t have a haughty body. She hesitated and occassiohally was murmuring to grow into him but nodded no again.

  6. Roger Clayton Says:

    aotncaj4f7f2xbvw

Leave a Reply



Site Navigation