Author: Feng limei,Hua Qing vision embedded college lecturer.
This document compares and analyzes bash configuration files in linux.
1. There are two global configuration files.
/Etc/profile: This file sets the environment information for each user in the system. This file is executed when the user logs on for the first time. And collect shell settings from the configuration file in the/etc/profile. d directory.
/Etc/bash. bashrc: execute this file for every user running bash shell. When bash shell is opened, the file is read.
2. There are bash configuration files in the user's home directory, which are local.
If you find. bash_profile, the file will be executed after/etc/profile is executed, if. bash_profile cannot be found. Find another file. bash_login, if. bash_login does not exist either. Find. profile and execute. Only one of the three files is operated. Next we will introduce ubuntu as an example.
~ /. Profile: each user can use this file to input shell information dedicated to their own use. When a user logs on, this file is only executed once! By default, it sets some environment variables to execute the user's. bashrc file.
~ /. Bashrc: This file contains bash information dedicated to your bash shell. This file is read when you log on and every time you open a new shell.
~ /. Bash_logout: execute this file every time you exit the system (exit bash shell. In addition, the variables (global) set in/etc/profile can act on any user ~ The variables (local) set in/. bashrc can only inherit the variables in/etc/profile. They are "Parent-Child" relationships.
3. Note that:
When setting environment variables, profile and bashrc can be written to each other, but they are indeed different.
Profile content, which is executed after system logon;
Bashrc is automatically executed when you log on to the shell.
That is to say, some accounts that do not use shell (such as ftp_administrator, etc.) must be written in the profile rather than another initialization program or variable.