Changes between Version 17 and Version 18 of FrequentQuestions/LinuxFu


Ignore:
Timestamp:
06/06/11 12:19:12 (14 years ago)
Author:
Brandon Shroyer
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • FrequentQuestions/LinuxFu

    v17 v18  
    5050}}}
    5151[[CollapsibleEnd]]
     52
     53== Bash Shell Configuration:  {{{.bashrc}}} and {{{.bash_profile}}} ==
     54
     55Whenever 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
     59In 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
     61For 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{{{
     63if [ -f ~/.bashrc ]; then
     64        source ~/.bashrc
     65fi
     66}}}
     67Aside 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]]
    5270== Command Aliasing ==
    5371