So Just What is Bashrc

You’re most likely using it without even knowing, but .bashrc is a script in your home directory that gets executed every time you start a shell. You’ve most likely updated this file if you have ever wanted an alias to be created (like to enable colors when running ls), or an environment variable to be altered (for example, appending something to PATH) for each instance of bash you start.

Included in most Linux distributions are both .bash_profile and .bashrc. The difference between the two is that .bash_profile is executed for “login shells” (when you login at a TTY or RSH/SSH/Telnet session), while .bashrc is executed for interactive non-login shell (ie. starting a shell from within another program or by /bin/bash). There is also a related file that executed on logout called .bash_logout.

Typically, most people will probably never remember the difference between the two files, and normally it does not matter because they are generally set up so that one will call the other. If not, you can prepend the following lines to your .bash_profile:

if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi

This should finally clears up for everyone! And don’t forget to check your man pages for more information.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 45 other followers