Which file to edit - .bashrc or .bash_profile?

Most of the new users get confused between these two files. Let me try to explain and put them in places.

A .bashrc file is a startup configuration file used with the Bourne-Again SHell (Bash). Bash is the most common shell on Linux systems The .bashrc file is used for personal aliases of commands, think shortcuts, and user-functions. Also you can set a personal customized welcome screen when you login to your terminal.

According to the bash man page, .bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells. This means if you login either physically or via SSH .bash_profile is executed.

However, if I launch Gnome Terminal or any other application is launched it will execute or look for content of .bashrc file.

Comments

2 Responses to “Which file to edit - .bashrc or .bash_profile?”

  1. synack on April 19th, 2007 3:52 am

    I prefer having “aliases” as a separate file which is “called” from .bashrc

    # my own aliases are found in .bash_aliases
    if [ -f $HOME/.bash_aliases ]; then
    source $HOME/.bash_aliases
    fi

    Another “must” is export HISTCONTROL=ignoredups in .bashrc, so that my history won’t become too long…

    IMHO, this is also nice:

    synack@deimos ~ $ cd projects/scripts/
    synack@deimos scripts $ pwd/home/synack/projects/scripts

    # Keeps the prompt “clean”

    Last, but not least (still in .bashrc):
    export SSH_ASKPASS=”/usr/bin/gtk2-ssh-askpass”
    /usr/bin/keychain –dir ~/.ssh ~/.ssh/id_rsa
    source ~/.ssh/deimos-sh > /dev/null

  2. Arstan on April 19th, 2007 4:23 am

    Thank you very much for your input on this matter synack! I would love to see more comments in the future!

Leave a Reply

You must be logged in to post a comment.

Categories


Clicky Web Analytics