1

According to the answer of the question, https://askubuntu.com/questions/155865/what-are-login-and-non-login-shells, gnome terminal is a type of non-login shell. As pointed out in the excellent book, A Practical Guide to Fedora and Red Hat Enterprise Linux, 6th Edition:

an interactive non-login shell executes commands in the ~/.bashrc file. The default ~/.bashrc file calls /etc/bashrc.

As a result, /etc/profile won't be processed in non-login shell. However,I found that I had append the java home path to the $PATH variable, when I use gnome terminal and issue the command java, everything goes fine and the value of $PATH variable is the same as the value I define in /etc/profile.

In view of the above-mentioned facts, there is a conflict, what’s wrong with my understanding?

2

When you log in to your x session via a display manager or in a tty, /etc/profile is (usually - apparently it is being in your case, though some graphical shells do not read it) sourced by your shell program. After that, a local file (I'm assuming you're using bash here) ~/.bash_profile, ~/.bash_login or ~/.profile will be sourced, and any environment variables defined here will override /etc/profile for the current user. This environment is inherited by any shell you open within the session. This is why we can define environment variables, such as your PATH, in these files.

When you open gnome-terminal, yes by default that starts a non-login shell, but it inherits your user environment already loaded from the login shell or graphical shell. Since ~/.bashrc is sourced when starting an interactive shell (eg opening gnome-terminal), it may be used to override some elements of the environment (such as PS1).

(gnome-terminal itself is an application, not a shell)

  • Do you have a reliable document that contain the detail you mentioned? – Blue Steel Sep 5 '16 at 15:48
  • I learned this from The Linux Command Line. I can find the relevant section in the pdf copy I have, but I don't think it's online... I will look for another source... @BlueSteel – Zanna Sep 5 '16 at 15:55
2

short: no

long: gnome-terminal is a terminal. You run a shell in a terminal. You can run either type of shell (login or not) in a terminal (though gnome-terminal makes it harder than other terminals).

Further reading:

0

Try this, it works in BASH.

shopt -q login_shell && echo " <<< It's a Login Shell >>> " || echo " <<< It's \"NOT\" a Login Shell >>> "

By the way, Gnome Terminal is just a terminal emulator(an application program) that uses shell(more specifically BASH).

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.