The difference and connection between profile, BASHRC, Bash_profile in Linux

Source: Internet
Author: User
Tags aliases

/etc/profile: This file sets the environment information for each user of the system, and the file is executed the first time the user logs on. and collects the shell settings from the configuration file of the/ETC/PROFILE.D directory.

The English description is:

#/etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases Go IN/ETC/BASHRC

# It's not a good idea to the change this file unless you know
# is doing. It ' s much better to create a custom.sh shell script in
#/etc/profile.d/to make custom changes to your environment, as this
# would prevent the need for merging on future updates.

So if you have a change to/etc/profile, you have to restart your changes to take effect, and this change will take effect for each user. If you want to take effect immediately, you can execute Source/etc/profile

/ETC/BASHRC: Executes this file for each user running the bash shell. When the bash shell is opened, the file is read.

The English description is:

#/ETC/BASHRC

# System wide functions and aliases
# Environment Stuff Goes In/etc/profile

# It's not a good idea to the change this file unless you know
# is doing. It ' s much better to create a custom.sh shell script in
#/etc/profile.d/to make custom changes to your environment, as this
# would prevent the need for merging on future updates.

If you want to modify a configuration for all users who use bash and then open it later, you can modify the file, modify the file without restarting, and reopen a bash to take effect.

. bash_profile
The. bash_profile file exists in the user's home directory, the relative path is: ~/.bash_profile, the absolute path is/home/$name/.bash_profile
The. bash_profile file is a hidden file that contains the environment variables of the user's user.

~/.bash_profile: Each user can use this file to enter shell information dedicated to their own use, when the user logs on, the file is only executed once! By default, he sets some environment variables to execute the user's . BASHRC file.

This file is similar to/etc/profile and requires a reboot to take effect,/etc/profile for all users, ~/.bash_profile only for the current user. If you want to take effect immediately, you can execute the source ~/.bash_profile
~/.BASHRC: This file contains bash information dedicated to your bash shell, which is read when you log in and every time you open a new shell. (Each user has a. bashrc file in the user directory)

This file is similar to/ETC/BASHRC, does not require a restart to take effect, reopen a bash to take effect,/ETC/BASHRC for all users of the new bash will take effect, but ~/. BASHRC is only valid for new bash that is currently opened by the current user.

~/.bash_logout: Executes the file each time it exits the system (exiting the bash shell).

In addition, the variables set in/etc/profile (global) can be applied to any user, while ~/. Variables set in BASHRC and so on (local) can only inherit variables from/etc/profile, they are "parent-child" relationships.

~/.bash_profile is interactive, login way into bash run;
~/.BASHRC is an interactive non-login way to go into bash running;
Usually the two settings are roughly the same, so the former usually calls the latter.

Transferred from: http://blog.csdn.net/chenchong08/article/details/7833242

Differences and connections between profile, BASHRC, Bash_profile in Linux (go)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.