2

I'm trying to understand a user login process on Centos 7 and I've gotten a bit confused trying to figure out when/how a Gnome terminal session defines environment variables (Gnome 3.14.4).

As near as I can tell.... a Gnome terminal will only define environment variables from the /etc/profile, ~/.profile, or ~/.bash_profile if the variables were exported in those scripts.

If they aren't exported then they don't appear in the output of either the set or printenv commands. The /etc/environment file is the exception (but it's not a shell login script).

The only thing I've found that looks like it would do this is the /etc/X11/xinit/xinitrc-common file when it sources the ~/.profile login script... But that's just a single login script and doesn't explain why exported variables in /etc/profile & ~!/.bash_profile are being displayed in set.

[ -r $HOME/.profile ] && . $HOME/.profile

If this reads the variables in the ~/.profile script... How are the variables being read for /etc/profile & ~/.bash_profile? If it matters.... I haven't selected "run command as login script"

1
  • Can you edit your question and add your ~/.bash_profile and ~/.bashrc? Dec 21, 2017 at 15:42

1 Answer 1

1

I believe the Gnome Terminal runs bash (the GNU Bourne Again SHell) by default.

Actually it probably runs whatever shell is specified for your account in /etc/passwd

On startup bash goes through ~/.profile and ~/.bash_profile, that's why those variables get set.

So to recap: when you start Gnome Terminal, it starts your shell, and your shell goes through these scripts setting the environment variables.

1
  • It runs whatever is specified by the SHELL environment variable.
    – JdeBP
    Dec 21, 2017 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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