Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using Gentoo and KDE 4, opening Konsole or xterm doesn't provide defined stuff in /etc/profile. This file is normally sourced by a login shell, but what can be considered as a login shell in a graphical environment? Is this supposed to be sourced before the X session? Should the shell of Konsole be set up with bash --login? Is this a bug?

Thanks for your help.

share|improve this question
sounds more SuperUser-y to me – warren Nov 24 '09 at 11:33
up vote 1 down vote accepted

It depends.

Unless the shell is launched as a "login shell", which is the system's way of signaling to the shell that this is the first time the user is interacting with the computer for this session, it is started as a "child" shell.

"Login" shells source the environment from whatever control mechanism is set up (/etc/profile, /etc/profile.d/, and usually local dotfiles like .profile and .bashrc (if bash)).

"Child" shells just inherit their parent's environment, but sometimes also run some dotfiles depending on how they are configured.

In most systems with X configured, the dot files are sourced by whatever process starts the window manager and xterms or konsoles or whatever just inherit from that. This is because it isn't considered a login session, since you were already logged in when you started the konsole.

You can set your konsole to run 'bash --login' if you want, but this might have unexpected side-effects later on when you run something which depends on an environment variable that you are clobbering with the --login parameter.

share|improve this answer

According to this page in the Gentoo Handbook, on Gentoo you'll want to define your environment variables in a file underneath the /etc/env.d directory, rather than in /etc/profile itself.

share|improve this answer
I know, /etc/profile is a gentoo script that setup different stuff coming from /etc/env.d/ as well as /etc/profile.d/ and which is not supposed to be modified. My problem is that /etc/profile is not sourced at all ignoring that kind of stuff too! – Patrick Allaert Nov 24 '09 at 12:06

A login shell is distinguished (by the shell interpreter) by starting with a "-". That is, argv[0] of a login bash shell will be -bash vice bash. Similarly for other shells (-ksh vs ksh, -csh vs csh, -sh vs sh, etc.) This is done by the login program or other authentication step. Bash offers the -l or --login option, but that should be the equivalent of -bash.

If you want to ensure that /etc/profile is read (instead of only setting up an inherited environment), you can explicitly read it in ~/.profile. Use the appropriate file names for your shell of choice.

share|improve this answer

I think this is a bug in gentoo... check your ~/.xsession-errors for an error involving 'keychain'...

emerging net-misc/keychain fixed it for me.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.