[Discuss] What the use of .bashrc

Jerry Feldman gaf at blu.org
Tue Oct 30 10:54:57 EDT 2012


On 10/30/2012 10:31 AM, Chris Tyler wrote:
> On Tue, 2012-10-30 at 07:50 -0400, Glenn Hoffman wrote:
>> I'm teaching an Introduction to Linux/Unix class at UMass/Boston. I've
>> just told the class about the different type of shells (login,
>> interactive non-login in, non-interactive) and the startup files for
>> each. I've never been able to give a class a good reason for the
>> existence of .bashrc, since I have never used it myself. What's the
>> reason for a separate startup file for a non-login interactive shell?
>>
>> Glenn
> .bashrc is useful for non-inheritable configuration.
>
> Environment variables are inheritable so they're usually placed
> in .bash_profile; but aliases are not inheritable, so they must be
> in .bashrc if you want them to be available in each shell you start.
>
BTW:
.profile is used for generic shell stuff, and should not have specific
BASH syntax.
.bash_profile is similar except it is essentially for BASH specific type
stuff or syntax.
.bashrc is for interactive shells and for setting aliases.
You can effectively not have a .profile and a .bash_profile, but you
should always have a .bashrc.

In the olden days, the Bourne Shell only has a .profile. The original C
Shell came up with the idea of a login shell profile (called .login),
and a per shell script (.cshrc). The idea was that the parsing of
scripts were performance related, so you placed most of your stuff in
.login, and only the necessary stuff in .cshrc. But, today, the time
spent parsing a .bashrc or .cshrc is usually miniscule. But, one issue
is that if you set your path in .bashrc or .cshrc, then yopu could have
the same element multiple times in your path (which is why I use
pathmunge().

-- 
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix
PGP key id:3BC1EB90 
PGP Key fingerprint: 49E2 C52A FC5A A31F 8D66  C0AF 7CEA 30FC 3BC1 EB90




More information about the Discuss mailing list