Login Shells
A login shell (also an interactive shell) is the first process that executes under your user ID when you log in for an interactive session.
Bash runs the following scripts on login:
Interactive Shells
An interactive shell 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. The user can interact with the shell. On entering an interactive terminal, Bash also executes:
Non-interactive shells
Non-interactive shells do not usually execute startup files, however different shells act differently. Bash always reads ~/.bashrc
when its invoked by rshd or sshd, even if its not interactive (but not if its called as sh). Zsh always reads ~/.zshenv
.
Also note that aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt:
Commands:
Sudo and su commands and shell type
Command | Interactive | Login |
---|---|---|
su |
Y | N |
su - , su -l |
Y | Y |
sudo -i |
Y | Y |
su vs sudo
Files to know
~/.bash_history
~/.bash_logout
~/.bashrc
~/.bash_profile