Contents
What is a bash login shell?
Login shell. A login shell is a shell given to a user upon login into their user account. This is initiated by using the -l or –login option, or placing a dash as the initial character of the command name, for example invoking bash as -bash. Sub shell.
What is the difference between an interactive and a non interactive shell?
A shell running a script is always a non-interactive shell. Simply put: Interactive shell require user input, while non-interactive shell are run by scripts and don’t require user inputs.
Why is Bash invoked as a non-interactive shell?
The –rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc. When bash is invoked as an interactive login shell, or as a non-interactive shell with the –login option, it first reads and executes commands from the file /etc/profile, if that file exists.
What’s the difference between a login shell and interactive Bash?
If a shell script (a file containing shell commands) is run, then it is neither a login shell nor an interactive one. Start-up files are highly tailorable in bash:
Why does SSH start a non interactive login shell?
When ssh is launched without a command (so ssh instead of ssh command which will run command on the remote shell) it starts a login shell. If the stdin of the ssh is not a tty, it starts a non-interactive shell. This is why echo command | ssh server will launch a non-interactive login shell. You can also start one with bash -l -c command.
How does the login process in Bash work?
The login process tells the shell to behave as a login shell with a convention: passing argument 0, which is normally the name of the shell executable, with a “ – ” character prepended Reads commands from user input on a tty. Among other things, such a shell reads startup files on activation, displays a prompt, and enables job control by default.