interactive/non-interactive, login/non-login shells

  • Bash Reference Manual - GNU
  • What is the difference between interactive shells, login shells, non-login shell and their use cases?
  • Difference between Login Shell and Non-Login Shell?
  • Cygwin Bash.exe vs. mintty.exe
    • If you run bash.exe or mintty.exe without options, you just get the naked shell, with its default configuration, which means it doesn’t do things like add the Cygwin /bin to your PATH.
interactive/non-interactive
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.
login/non-login
A login shell is one whose first character of argument zero is -, or one invoked with the --login option.

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. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. When a login shell exits, Bash reads and executes commands from the file ~/.bash_logout, if it exists.

你可能感兴趣的:(shell,bash,login,gnu)