Bash's most common activation mode

Source: Internet
Author: User
Article title: Bash's most common activation mode. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The most common activation modes of Bash are interactive and non-interactive:
1. interactive activation
The standard input and output are connected to the terminal. There are three types: login, non-login, posix, and restricted shell.
Check whether a shell is interactive. you can check the $ PS1 environment variable.
(1) when Bash is activated as the login shell, it reads and runs the following files in sequence:/etc/profile ,~ /. Bash_profile ,~ /. Bash_login ,~ /. Use the -- noprofile option to activate Bash. you can disable it from reading any initialization file and execute it when exiting ~ /. Bash_logout file
(2) when Bash is activated as a non-login shell, it will read and execute ~ /. When bashrc uses the -- norc option to activate Bash, any initialization file cannot be executed, and the -- rcfile file can be used to specify the initialization file to be executed.
(3) when Bash is activated as the posix mode, it first checks whether the $ ENV variable is defined. if it is defined, Bash reads and executes the file with $ ENV variable extension. otherwise, no initialization file is executed.
(4) when Bash is activated as the restricted mode, it does not prohibit some operations, but other actions are the same as those in other modes. restricted operations include changing directories, modifying $ SHELL and $ PATH variables, running exec, running programs in absolute paths, and using redirection. bash 1. x does not contain the restricted mode.
2. non-interactive activation is mainly used to run the Shell script. after the startup, Bash checks the $ BASH_ENV variable. if it is defined, the command contained in the specified file is executed.
  
Bash activation options
-C string this option indicates that the string contains a command, such as bash-c ls ~
-I used Bash to run in interactive mode
-R enables Bash to run in Restricted Mode
-- Login enables Bash to run in Shell login mode
-- Posix enables Bash to comply with POSIX standards
-- Verbose enables Bash to display all input rows it reads
-- Help print Bash usage information
-- Version: prints version information.
-- Noprofile
-- Norc
-- Rcfile file
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.