您的位置:首页 > 运维架构 > Shell

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

2015-08-26 23:25 726 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: