[Gllug] .bash_profile & .bashrc

Stuart Sears stuart at sjsears.com
Mon Aug 30 12:14:18 UTC 2004

On Monday 30 August 2004 09:02, Andrew Black (li) wrote:
> Hi
> I am confused between the files - .bash_profile & .bashrc
> I am trying to put some customised alias and $PATH etc and am finding
> things are different between a Konsole session and an SSH session.
an ssh session doesn't give your full login environment
most konsole (and other x terminal emulators) sessions are non-login shells
> What is the rationale for putting things into either file.
see below for RH-style setups
> On related point, if I want soemthing to be defined for all users, is it
> legit to create  it to a file in  the directory /etc/profile.d.
> I have done this and it works but it appears tobe called twice (so if you
> add to $PATH it happens twice :-( )
this will depend in part on which distro you are running -
originally Mandrake was just RH recompiled and they may still do things the 
same way. What's in your ~/.bash_profile?
The RH distros write the bash startup scripts so they are read in the 
following order:
1) login shell
~/.bashrc : called from ~/.bash_profile (Mandrake may not do this)
/etc/bashrc : called from ~/.bashrc (ditto)
/etc/profile.d/* : run by a loop in /etc/profile

2) non-login shell
/etc/bashrc : as above
/etc/profile.d/* : run by a loop in /etc/bashrc

Aliases and functions on a per-user basis will mostly go into ~/.bashrc as 
this file is read for both login and non-login shells

Environment variables usually go into ~/.bash_profile (ie read once at login. 
non-login shells you open will most likely be subshells of the login shell, 
and will inherit its variables.)

Global changes to paths should be done in /etc/profile (in fact user PATH and 
other vars are set in here)

Scripts that you wish to run for every user should be dumped in /etc/profile.d
- they will be read for both login and non-login shells

> I am using Mandrake 9 if that is relevant
haven't checked out how this does it but originally Mandrake was just RH 
recompiled and they may still do things this way
> Andrew

Stuart Sears RHCE, RHCX 
   Sometimes I think the surest sign that intelligent life exists elsewhere in
the universe is that none of it has tried to contact us.  -- Calvin
Gllug mailing list  -  Gllug at gllug.org.uk

More information about the GLLUG mailing list