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
MySQL handles GROUP BY and DISTINCT queries simil...
Detailed example of removing duplicate data in My...
Problem Description After installing Qt5.15.0, an...
I recently upgraded MySQL to 5.7, and WordPress r...
Usage scenarios For existing servers A and B, if ...
> Deploy MySQL 5.7 cluster master & slave ...
Why did I use this? It all started with the makin...
Description of the phenomenon: The project uses s...
Table of contents 1. Example: this can directly g...
Recently, a friend asked me a question: When layo...
Perform the following operations in the Ubuntu co...
Insert image tag <IMG> The colorful web page...
Table of contents 1. Get the first link first 2. ...
Create a new server.js yarn init -y yarn add expr...
<br />Hello everyone! It’s my honor to chat ...