Question: What's the difference between `.bashrc` and `.bash_profile` and which one should I use?

Answer: 
From this [short article](http://joshstaiger.org/archives/2005/07/bash_profile_vs.html)

> 
> According to the bash man page,
>  .bash\_profile is executed for login
>  shells, while .bashrc is executed for
>  interactive non-login shells.
> 
> 
> **What is a login or non-login shell?**
> 
> 
> When you login (eg: type username and
>  password) via console, either
>  physically sitting at the machine when
>  booting, or remotely via ssh:
>  .bash\_profile is executed to configure
>  things before the initial command
>  prompt.
> 
> 
> But, if you've already logged into
>  your machine and open a new terminal
>  window (xterm) inside Gnome or KDE,
>  then .bashrc is executed before the
>  window command prompt. .bashrc is also
>  run when you start a new bash instance
>  by typing /bin/bash in a terminal.
> 
> 
>
Have a look at this [excellent blog post by ShreevatsaR](http://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/). Here's an extract, but go to the blog post, it includes an explanation for terms like "login shell", a flow chart, and a similar table for Zsh.

> 
> For Bash, they work as follows. Read down the appropriate column. Executes A, then B, then C, etc. The B1, B2, B3 means it executes only the first of those files found.
> 
> 
> 

```
+----------------+-----------+-----------+------+
|                |Interactive|Interactive|Script|
|                |login      |non-login  |      |
+----------------+-----------+-----------+------+
|/etc/profile    |   A       |           |      |
+----------------+-----------+-----------+------+
|/etc/bash.bashrc|           |    A      |      |
+----------------+-----------+-----------+------+
|~/.bashrc       |           |    B      |      |
+----------------+-----------+-----------+------+
|~/.bash_profile |   B1      |           |      |
+----------------+-----------+-----------+------+
|~/.bash_login   |   B2      |           |      |
+----------------+-----------+-----------+------+
|~/.profile      |   B3      |           |      |
+----------------+-----------+-----------+------+
|BASH_ENV        |           |           |  A   |
+----------------+-----------+-----------+------+
|                |           |           |      |
+----------------+-----------+-----------+------+
|                |           |           |      |
+----------------+-----------+-----------+------+
|~/.bash_logout  |    C      |           |      |
+----------------+-----------+-----------+------+

```