The difference between profile and bashrc

The difference between profile and bashrc under Linux

12160 reads 0 comments

/etc/profile, /etc/bashrc, ~/.bash_profile, ~/.bashrc are easily confused, what is the difference between them? What exactly do they do?
/etc/profile: Used to set system environment parameters, such as $PATH. The environment variables in this are valid for all users in the system.
/etc/bashrc: This file sets things related to the system bash shell and takes effect for all users in the system. The stuff in here works as long as the user runs the bash command.
~/.bash_profile: Used to set some environment variables, the function is similar to /etc/profile, but this is set for users, that is, you set environment variables in /home/user1/.bash_profile, Then this environment variable only takes effect for the user user1.
~/.bashrc: The function is similar to /etc/bashrc, only for the user himself, not for other users.
In addition, the variables (global) set in /etc/profile can act on any user, while the variables (local) set in ~/.bashrc can only inherit the variables in /etc/profile, they are "father and son" Relation.
~/.bash_profile is run interactively and logged into bash, which means that it will only take effect when the user logs in.
~/.bashrc is run by entering bash in interactive non-login mode. The user is not necessarily logged in, as long as the command line is run as the user, the file will be read.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325855702&siteId=291194637