First, what is the landing shell? What is a non-landing shell?
1. Landing shell means:
(1) When the user logs on, enter the user name and password to start the shell;
(2) through the command with the--login parameter: The shell launched by Bash--login.
2. Non-login Shell refers to:
After the user logs on, run the Bash command to launch the shell directly.
3. For users, the main difference between landing shell and non-landing shell is that the startup file executed when the shell was started is different.
(1) The startup file of the login shell is/etc/profile, ~/.bash_profile
(2) The boot file of the non-login shell is ~/.BASHRC
Second, the operation mode of bash
Interactive shell
The interactive mode is where the shell waits for your input and executes the commands you submit. This pattern is called interactive because the shell interacts with the user.
This mode is also familiar to most users: Log in, execute some commands, and check back. When you sign back, the shell also terminates.
Interactive mode is divided into four types: login, non-login,posix, and restricted shell.
Determines whether a shell is interactive and can be detected by $PS1 environment variables.
(1) When Bash is activated as the login shell, it reads and executes the following files in turn:
/etc/profile,~/.bash_profile,~/.bash_login,~/.profile
Use the--noprofile option to activate Bash to prevent it from reading any of the initialization files
Execute ~/.bash_logout file on exit
(2) When Bash is activated as a non-login shell, it reads and executes the ~/.BASHRC
Use the--NORC option to activate Bash to prevent any initialization files from being executed, using the
The--rcfile file can specify the initialization files to execute.
(3) When Bash is activated as a POSIX mode, it will first check whether the $ENV variable is defined.
If defined, bash reads and executes files obtained with the $env variable extension, otherwise it is no longer
Executes any initialization files.
(4) When Bash is activated as a restricted mode, it does not only prohibit certain actions, but other behaviors
Same as other modes. Restricted operations are: changing directories, modifying $shell and $path variables,
Run exec, run the program in an absolute path, and use redirection. Bash 1.x does not contain
Restricted mode.
Non-interactive shell
The shell can also run in a different mode: non-interactive mode. In this mode, the shell does not interact with you,
Instead, they read the commands stored in the file and execute them. When it reads the end of the file, the shell terminates. This
Mode is used primarily to run shell scripts. After startup, BASH checks the $bash_env variable, if defined, which executes the variable specified by the file
The commands contained in the.
Activation options for Bash
-C String This option indicates that a command is included in the string. such as Bash-c ls ~
-I enables bash to run interactively
-R makes bash run in restricted mode
--login make bash run as login shell
--posix bash adherence to the POSIX standard
--verbose make bash Show all input lines that it reads into
--help to print bash usage information
--version Print version Information
--noprofile
--norc
--rcfile file
Shell's operating mode