SHELL script strategy (learning notes) -- 1.5 bash environment configuration process, -- 1.5 bash

Source: Internet
Author: User

SHELL script strategy (learning notes) -- 1.5 bash environment configuration process, -- 1.5 bash

From the perspective of user login, shell is divided into two types:

Logon shell: If you log on through a terminal, use the su-username command to switch users.

Non-interactive shell: for example, you can use the su username command to switch between users. Open the command terminal and shell script in the graphic terminal.

A simpler but inaccurate differentiation method is: non-interactive shells that do not need to enter the account and password to log on, such as subshells, script shells, and command windows opened in graphic terminals, except for su username.

Bash environment configuration file:

Global configuration:/etc/profile,/etc/profile. d/*. sh,/etc/bashrc.

Personal Configuration :~ /. Bash_profile ,~ /. Bashrc.

The read and execute environment configuration files are sequential. If the settings conflict, the configuration files read later overwrite those read first.

Procedure for reading the configuration file:

The log-on shell reads the environment configuration files in the following sequence:

(1)/etc/profile -->/etc/profile. d/*. sh
(2 )~ /. Bash_profile --> ~ /. Bashrc -->/etc/bashrc

Read the global configuration file/etc/profile before reading the user configuration file ~ /. Bash_profile. However, the/etc/profile file will call all. sh files in the/etc/profile. d/directory ,~ /. Bash_profile will call ~ /. Bashrc file ,~ /. Bashrc will call the/etc/bashrc file again. In fact,/etc/bashrc will also call/etc/profile. d/*. sh, but it will not repeat the set options.

The order in which non-Logon shell reads environment configuration files is:

~/.bashrc-->/etc/bashrc-->/etc/profile.d/*.sh

 

That is to say:

/Etc/profile: read when any user logs in. Non-Logon shell does not read data.

~ /. Bash_profile: it is read when the user logs on to configure the bash shell to be opened. Non-Logon shell does not read data.

~ /. Bashrc: For the bash shell configuration, the corresponding user will read the file every time he opens a shell, because the login or non-login shell will read the file.

/Etc/bashrc: (all users) the file is read every time a shell is opened (login or non-login.

Back to series article outline: http://www.cnblogs.com/f-ck-need-u/p/7048359.html

Reprinted please indicate the source: http://www.cnblogs.com/f-ck-need-u/p/7229025.html

 

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.