- Interactive shell and non-interactive shell (interactive shell and non-interactive shell)
The interactive mode is executed on the terminal, the shell waits for your input, and executes the command you submitted immediately. This pattern is called interactive because the shell interacts with the user. This pattern is also familiar to most users: Log in, execute some commands, and exit. When you quit, the shell also terminates.
The shell can also run in a different mode: non-interactive mode, executed in shell script (non-interactive) way. In this mode, the shell does not interact with you, but instead reads the commands stored in the file and executes them. When it reads the end of the file, Eof,shell terminates.
You can distinguish between interactive and noninteractive shells by printing the value of the "$-" variable (which represents the option flag for the current shell) and viewing the "I" option (representing the interactive shell).
[Email protected]:~/workspace/shell$ Echo $-
Himbh
[Email protected]:~/workspace/shell$./test.sh
Echo $-
Hb
- Login shell and non-login shell
Login Shell: A shell that requires a username, password login to enter (or a shell generated through the "–login" option).
Non-logon shell: Of course, you do not need to enter a user name and password to open the shell, for example: direct command "Bash" is to open a new non-login shell, in GNOME or KDE open a "terminal" (terminal) window program is also a non-login shell.
Execute Exit command to exit a shell (login or non-login shell);
Execute the logout command to exit the login shell (you cannot exit the non-logon shell).
The initial whole process for a login bash environment is:
/etc/profile
|
--/etc/profile.d/*
~/.bash_profile
|
--~/.bashrc
|
--/etc/bashrc
|
--/etc/profile.d/*
The initial whole process of a normal interactive bash is:
~/.bashrc
|
--/etc/bashrc
|
--/etc/profile.d/*
The initial whole process for non-interactive bash is:
Do not re-source any new shell scripts, only inherit the settings of the current shell
Logon and non-logon & interactive and noninteractive shell and its environment initialization process