About the shell, where is the environment variable placed?

Source: Internet
Author: User

When using the shell, the environment variable file is read.

/etc/profile: This file sets the environment information for each user for the system, and the file is executed when the user logs on for the first time.

and collect the shell settings from the configuration file of the /etc/profile.d directory.


/ETC/BASHRC : executes this file for each user running the bash shell. When the bash shell is opened, the file is read.
~/.bash_profile : Each user can use this file to enter shell information dedicated to their own use, when the user logs on, the
The file is only executed once! By default, he sets some environment variables to execute the user's. bashrc file.

~/.bash_profile is executed only once, setting some environment variables
~/.BASHRC : This file contains bash information dedicated to your bash shell, and when you log in and each time you open a new shell, the
The file is read.

~/.bash_logout: Executes the file each time it exits the system (exiting the bash shell).

bash_profile ,. BASHRC , and. Bash_logout

The above three files are the user Environment profile for the bash shell, which is located in the user's home directory. . Bash_profileIs the most important configuration file that is read every time a user logs on to the system, and all commands inside it are executed by bash. Profile (used by Bourne Shell and Korn shell) and. Login (used by C shell) two files are. bash_ The synonym for profile is intended to be compatible with other shells. use the. profile file in Debian instead of the. bash_profile file.

The . BASHRC file is read when the bash shell invokes another Bashshell, which is the file that is read when the Bash command is typed in the shell to launch a new shell. This effectively separates the environments required for logins and child shells. But in general, it will be called in. bash_profile. BASHRC scripts for unified configuration of user environments.

. Bash_logoutis read when exiting the shell. So we can put some clean-up orders into this file.

When you log in to Linux, start the/etc/profile file first, and then start one of the ~/.bash_profile, ~/.bash_login, or ~/.profile files in the user directory (depending on the different Linux operating systems, names are different), the order of execution is: ~/.bash_profile, ~/.bash_login, ~/.profile.

If the ~/.bash_profile file exists, the ~/.BASHRC file is typically executed.

About the shell, where is the environment variable placed?

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.