Non-interactive & non-login shell environment?

General support questions
Posts: 24
Joined: 2015/06/06 23:55:29

Non-interactive & non-login shell environment?

Postby bodisha » 2017/11/16 16:09:51

Hello and thanks in advance for any help anyone can offer to straighten me out on this subject

I'm trying to understand non-interactive & non-login shells and having a hard time conceptualize the process a non-interactive & non-login shell goes through to start up. The way I understand things is when a script or a process is started.... a region of memory is created and the child process replicates a duplicate environment of the parent by being forked

What's confusing me is when is the shell environment defined? When I think about how an interactive shell is started I get a little lost.

The way I understand an interactive shell is:
1) User passes login ID to Linux kernel 2) Linux kernel looks the user up in the /etc/password file and identifies the assigned shell 3) the shell is started 4) the shell reads the login scripts to define the shell environment for the user 5) Linux produces a command prompt to indicate the shell is ready to accept commands

Is the process for a non-interactive & non-login shell similar? This is how I envision it working:
1) The process is forked by the parent process 2) Linux identifies the user ID the process will runs as 3) Linux looks the user id up in the /etc/password file 4) the shell is started 5) the BASH_ENV is read (If it was defined) 6) the process interacts with the shell to pass commands to the API

For some reason this seems clunky and like I'm missing something... Could someone let me know if I'm on the right path please?

Thank you very much!