Frequently Asked Question
What is the difference between a login shell and an interactive shell?
These are two different axes, not synonyms. A login shell is one started by the
login process, when you sign in at a virtual console, over SSH, or in a graphical
display manager that runs a login shell. It's the shell that sets up your
environment for the whole session. A non-login shell is anything started later:
opening a new tab in your terminal emulator, running bash from within another
shell, or executing a script.
An interactive shell is one with a prompt, you type, it responds. A non-interactive
shell is one running a script with no prompt. The two axes combine: an SSH login is
both interactive and login; opening a new terminal window is interactive but not
login; running bash myscript.sh is non-interactive and non-login. The distinction
matters because bash reads different startup files in each case: login shells read
~/.bash_profile, interactive non-login shells read ~/.bashrc, and
non-interactive shells read neither unless BASH_ENV is set.