Linux environment variable settings file

  
        Environment variables in Linux include system level and user level. System level environment variables are system variables that are read by each user who logs in to the system. User level environment variables are environment variables that the user uses to load the system. So the files that manage environment variables are also divided into system level and user level. System level: /etc/profile This file sets the environment information for each user of the system. When the user logs in for the first time, the file is executed. And collect the shell settings from the configuration file in the /etc/profile.d directory. So if there is a change to /etc/porfile, you must restart the machine to take effect. This modification will take effect for each user. /etc/bashrc This file is executed for each user running the bash shell. This file is read when the bash shell is opened. If you want to modify a configuration for all users who use bash and bash will be effective in the future, you can modify this file, modify the file without restarting, reopen a bash or execute the source /etc/bashrc command to take effect. User level: ~/bash_profile Each user can use this file to enter shell information that is specific to the current user. When the user logs in, the file is only executed once. By default, it sets some environment variables to execute the user's .bashrc file. This file is similar to /etc/porfile and requires a reboot to take effect. /etc/porfile is effective for all users. ~/.bash_profile only works for the current user. ~/.bashrc This file contains bash information specific to the current user's bash shell, which is read when logging in and each time a new shell is opened. This file is similar to /etc/bashrc, does not require a restart to take effect, reopen a bash or execute source ~/.bashrc to take effect, /etc/bashrc is valid for all newly opened bash for all users, but ~/.bashrc only The newly opened bash of the current user takes effect.
Copyright © Windows knowledge All Rights Reserved