/etc/profile and ~/.bash_profile are not being read

Cameron Hutchison camh+ubuntu at xdna.net
Wed Nov 17 02:26:38 UTC 2004

Once upon a time janne said...
> tis 2004-11-16 klockan 17:48 -0800 skrev Vram:
> > It is my understanding that .bash_profile is read on login
> It should be. It isn't. That is the basis of my question :)

Vram's understanding is subtly incorrect. .bash_profile is read by a
login shell (one started with the -l parameter or where the name of the
zeroth argument starts with a dash).

The login(1) program runs on the console, and when it invokes bash, it
runs it as -bash, letting bash know it is a login shell. bash will then
run .bash_profile.

When you log in through gdm (or some other X display manager), bash is
not invoked. As such, there's no reason for .bash_profile to be read.
The display manager know nothing of this file, nor should it. Likewise
for the gnome session startup program.

Since the user may not even use bash (perhaps csh, or even a shell of
their own concoction) there is no way for the graphical login program to
know what script the user may have created to set up the environment.
Nor is there a standard way of invoking "shells" to tell them to set up
the environment and then exec another program. This is essentially what
is needed to allow each user to have their own specific shell, yet have
the environment set up by that shell as part of the graphical login

To get around this, I have my own .xsession that has a first line of
"#!/bin/bash -l". My startup is then done through the .xsession script,
after having loaded the bash environment. Users with different shells
would need a different first line to invoke their shell as a login

More information about the ubuntu-users mailing list