| 52 | |
| 53 | == Bash Shell Configuration: {{{.bashrc}}} and {{{.bash_profile}}} == |
| 54 | |
| 55 | Whenever you launch a {{{bash}}} shell via terminal, the shell environment is configured by the {{{.bash_profile}}} and {{{.bashrc}}} files in your home directory. The two files theoretically fulfill different roles, but the functionality they provide is very similar. |
| 56 | * The {{{.bash_profile}}} shell is executed when the you are logging in, be it through SSH, SFTP, or some other means. Basically, any launch that requires a username and password will execute the options {{{.bash_profile}}}. |
| 57 | * The {{{.bashrc}}} file, in contrast, is automatically executed when a non-login interactive shell is launched. For instance, if you are logged directly into a Linux machine and open a terminal window on the desktop, then {{{.bashrc}}} will be used instead of {{{.bash_profile}}}. |
| 58 | |
| 59 | In practice, it's better to keep all of your environment settings in one of the two files. Otherwise, you'll have to change two files in order to change your shell environment. If for instance, a library path or module was changed in {{{.bashrc}}} and the change wasn't propagated to {{{.bash_profile}}}, then the new option might be unavailable for remote users (who log into the system, and therefore trigger {{{.bash_profile}}}). |
| 60 | |
| 61 | For this reason, we usually put all of our environment configuration command in {{{.bashrc}}} and just add some lines to {{{.bash_profile}}} that invoke {{{.bashrc}}}: |
| 62 | {{{ |
| 63 | if [ -f ~/.bashrc ]; then |
| 64 | source ~/.bashrc |
| 65 | fi |
| 66 | }}} |
| 67 | Aside from this, {{{.bash_profile}}} is best kept relatively empty. This ensures that {{{.bash_profile}}} doesn't contain any settings that might override the ones in {{{.bashrc}}}. |
| 68 | |
| 69 | [[BR]] |