Bash interactive login shell vs interactive non-login shell
Here just talks interactive shells, not non-interactive ones.
I use Bash.
Design
One login shell at the top, and it spawns non-login shell. Non-login shells inherits most but *not* all settings from parent shell. So we should do heavy lifting work during login shell initialization, and left easy ones for non-login shell, e.g. run df/uptime after login.
- What's the difference?
login shell: when login via TTY or SSHnon-login shell: when run screen or bash
Startup files
Files are executed in this order. Taken from my VPS ubuntu image, your system might be different.
- login shell (bash -l)
/etc/profile/etc/bash.bashrc (sourced by /etc/profile)~/.bash_profile~/.bash_login~/.profile (will NOT run if .bash_profile or .bash_login exists)~/.bashrc (sourced by ~/.profile)~/.bash_logout (invoked when logout)
- non-login shell: (bash)
/etc/bash.bashrc
~/.bashrc
Comments
Post a Comment