In the Linux system, environment variables can be roughly divided into system-level environment variables and user-level environment variables according to their scope of application.
Naturally, the configuration files of environment variables are also divided into system-level and user-level ones. System Level /etc/profile It runs when the first user logs in after the system starts, and collects shell settings from the configuration files in the /etc/profile.d directory. The environment variables configured using this file will be applied to every user who logs in to the system. Tip: In Linux system, use the following command to make the configuration file take effect immediately. source /etc/profile echo $PATH /etc/bashrc (/etc/bash.bashrc in Ubuntu and Debian) It runs when the bash shell is opened. Modifying the environment variables configured in this file will affect the bash shell used by all users. Note: There are different categories of bash shells here, and the environment variable configuration files used by different categories are also different. Normally, a non-login shell will not execute any profile files, and a non-interactive shell mode will not execute any bashrc files. # Login shell and non-login shell: Login shell # You need to enter the user password. For example, ssh login or su - command privilege escalation will start the login shell mode non-login shell # No need to enter the user password; # Interactive shell and non-interactive shell: Interactive shell # Providing a command prompt to wait for the user to enter commands is interactive shell mode Non-interactive shell # Directly running a script file is non-interactive shell mode /etc/environment It runs when the system starts. It is used to configure environment variables that are related to system operation but not related to the user. Modifying the environment variables configured in this file will affect the global environment. User Level ~/.profile (recommended) This file is executed when the user logs in. Each user can use it to configure their own shell information. ~/.bashrc The file will be read when the user logs in and each time a new shell is opened. It is not recommended to configure user-specific environment variables here, because the file will be read once each time a shell is opened, which will definitely affect efficiency. ~/.bash_profile or ~./bash_login ~/.bash_profile or ~./bash_login - If one of these files exist, bash executes it rather then "~/.profile" when it is started as a login shell. (Bash will prefer "~/.bash_profile" to "~/.bash_login"). However, these files won't influence a graphical session by default. The above is the description of ~/.bash_profile and ~./bash_login given by Ubuntu official website, translated into Chinese: ~/.bash_profile or ~./bash_login - ~/.bash_logout This file is executed every time you exit the system (exit the bash shell). Note: Linux system uses $VARIABLE_NAME to access environment variables, and multiple environment variables are separated by :. Windows system uses %VARIABLE_NAME% to access environment variables, and multiple environment variables are separated by ;. Generally, the execution order of Linux loading environment variable configuration files is: ==> /etc/profile ==> ~/.bash_profile | ~/.bash_login | ~/.profile ==> ~/.bashrc ==> /etc/bashrc ==> ~/.bash_logout This is the end of this article about the introduction of Linux environment variable files. For more relevant Linux environment variable files, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: MySQL multi-table join introductory tutorial
>>: JavaScript to achieve custom scroll bar effect
Background Recently, when writing SQL statements,...
As a commonly used database, MySQL requires a lot...
1 / Copy the web project files directly to the we...
Recently I need to change the version of MySQL da...
1. Check whether MySQL is installed yum list inst...
Common scenarios for Nginx forwarding socket port...
For Windows User Using openGauss in Docker Pull t...
Preface Some of the earlier codes on Github may r...
After VMware is abnormally shut down, it prompts ...
This article shares the specific code for canvas ...
Table of contents Preface advantage: shortcoming:...
Table of contents The node version does not corre...
Cooper talked about the user's visual path, w...
Problem description: The user has a requirement t...
In a web page, the <input type="file"...