[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash not running ~/.bash_profile

James Buchanan wrote:
> For some reason my ~/.bash_profile and ~/.bashrc are not being executed 
> by bash.  Is there some way I can fix this problem?

Under what circumstances?  I will assume you are trying to log into
kdm, gdm, or xdm as that seems typical for people asking your

If you search the mailing list archive for xsession you will find lots
of previous discussion about it.  But it seems to have been a while.
Even though I use fvwm myself I am going to answer this as if it were
a kde user.  It is all the same, really.

You can have your .bash_profile environment by starting a login shell.
Create ~/.xsession with the following:

  #!/bin/bash --login
  exec x-session-manager # or gnome-session or startkde or fvwm or whatever.

Make sure it is executable or it will have no effect.

  chmod a+x ~/.xsession

Then when you log into kdm or gdm or xdm be sure to select "default"
for the session type.  That will run the ~/.xsession as a script and
it will read your ~/.bash_profile and launch your window manager and
everything will inherit.

You can stop reading now.  But for those interested in further details
here is some more low level information.

This is by the design of the KDE folks upstream.  Please see this KDE
FAQ entry.


  9.7.  KDE (kdm) does not read my .bash_profile!".  The login
        managers xdm and kdm do not run a login shell, so .profile,
        .bash_profile, etc. are not sourced.  When the user logs in,
        xdm runs Xstartup as root and then Xsession as user.  So the
        normal practice is to add statements in Xsession to source the
        user profile.  Please edit your Xsession and .xsession files.

I don't particularly like the way KDM/KDE is set up in this regard.
But changes should happen upstream in order to change and improve this

martin f krafft previously posted a bug against kdm and there has been
some discussion logged.  I just posted a summary of the various d-u
discussions there.


I like the technique of using #!/bin/bash for Xsession and then using
'exec -l' to start the shell.  It seems like a better solution than
~/.xsession using a login shell.  It promotes compatibility between
distros.  It solves a long running problem for newbies.  It loads the
login environment regardless of using [gkx]dm 'default' or selecting a
specific window manager.

Now that sarge is out it would be good to drive on this again.  But
soon there will be the transition to x.org packages.  So I will hold
myself back until I can look to see how the x.org packages are
organized.  That would be the place to fix this if it needs fixing


Attachment: signature.asc
Description: Digital signature

Reply to: