Linux on the difference between BASHRC and profile (RPM)

Source: Internet
Author: User
Tags terminates

Linux on the difference between BASHRC and profile (RPM)

The difference between BASHRC and profile

To understand the difference between BASHRC and profile, first figure out what the interactive shell and non-interactive shell are, and what the login shell and non-login shell are.

The interactive mode is where the shell waits for your input and executes the commands you submit. This pattern is called interactive because the shell interacts with the user. This mode is also familiar to most users: Log in, execute some commands, and check back. When you sign back, the shell also terminates. The shell can also run in a different mode: non-interactive mode. In this mode, the shell does not interact with you, but instead reads the commands stored in the file and executes them. When it reads the end of the file, the shell terminates.

BASHRC and profile are used to save the user's environment information, BASHRC is used for interactive Non-loginshell, and profile is used for interactive login shell. There are many BASHRC and profile files in the system, which are described below:

/etc/pro This file sets the environment information for each user of the system, and the file is executed when the first user logs on.

and collect the shell settings from the configuration file of the/ETC/PROFILE.D directory.

/ETC/BASHRC: Executes this file for each user running the bash shell. When the bash shell is opened, the file is read. There are no BASHRC files in the/etc directory in some Linux versions.

~/. Pro Each user can use this file to enter shell information dedicated to their own use, and when the user logs in, the

The file is only executed once! By default, it sets some environment variables and then executes the user's. bashrc file.

~/.BASHRC: This file contains bash information dedicated to a user's bash shell, which is read when the user logs on and every time a new shell is opened.

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

A netizen summarizes as follows:

/ETC/PROFILE,/ETC/BASHRC is the system Global environment variable setting
~/.PROFILE,~/.BASHRC private environment variable settings in the user home directory
When a shell process is acquired while logged into the system, it has three steps to read the Environment profile
1 first read the Global environment variable profile/etc/profile, and then read the additional set of documents according to its contents, such as
/ETC/PROFILE.D and/ETC/INPUTRC
2 then according to different user account, go to their home directory read ~/.bash_profile, if this can not read the ~/.bash_login, this also can not read to read
~/.profile, these three document settings are basically the same, reading has a priority relationship
3 then read the ~/.BASHRC according to the user account
As for the difference between ~/.profile and ~/.BASHRC
are individually customizable
~/.profile can set the user's proprietary path, environment variables, etc., it only to log in when the execution of the time
~/.BASHRC is also a user-specific settings document, you can set the path, command alias, each time the shell script execution will use it once


Linux on the difference between BASHRC and profile (RPM)

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.