2

I have somehow thought that all shells that are invoked by a terminal emulator or any other way while a user is logged in are subshells of the log-in shell. Is this correct?

If it matters, I am thinking of bash, Ubuntu, and gnome terminal.

norio
  • 205
  • Do you really mean subshells or child processes? A subshell is a specific type of shell which is a copy of its parent. See COMMAND EXECUTION ENVIRONMENT in man bash for instance. Also, you are only talking about shells launched in the GUI in a terminal emulator, right? – terdon Dec 24 '20 at 11:17
  • 1
    I mean subshell, not a subprocess. I know that all processes are child of init or systemd, and I have assumed that shells have an analogous hierarchy, so that environment variables set by log-in shells are succeeded to non-login shells invoked later during the session. And, yes, I had GUI terminal emulators in mind. – norio Dec 24 '20 at 11:20
  • 1
    Yes, OK. You are describing child shells, and not subshells. I know the terminology is confusing, but the two are not the same thing. See COMMAND EXECUTION ENVIRONMENT in man bash and also Is a sub-shell the same thing as a child-shell. – terdon Dec 24 '20 at 11:28
  • I read COMMAND EXECUTION ENVIRONMENT and the post, but got confused. I don't get what a child shell is. Is it invoked when I do $sh -c <my_program>? I think I understand that that section in man page explains that a subshell is launched when a command is executed from a shell. – norio Dec 24 '20 at 11:42
  • What do you mean by “the log-in shell”? If you start your desktop environment from a login manager (gdm, lightdm etc.), there isn’t a single parent shell for your session. – Stephen Kitt Dec 24 '20 at 12:08
  • 1
    Oh, I didn't know that.. My assumption was that a shell was working behind the scene when I type in my password on the log-in screen and desktop is being shown. If what you said is right, what is the mechanism for ~/.profile or ~/.bash_profile to be read in to the environment? How are $HOME and $PATH set for me as a user? – norio Dec 24 '20 at 12:24

0 Answers0