The use and difference of Linux BASHRC and profile

Source: Internet
Author: User

After using terminal ssh to login to the Linux operating system console, a prompt symbol (e.g. #或 ~) will appear, after which the command can be entered, and Linux responds with the input command, which is handled by a so-called shell.

The shell is a program, and the most common is bash, which is the shell that the login system will use by default.

Both the BASHRC and profile are shell startup settings files (in fact, these two files are also shell scripts), you can initialize the environment variables for the current shell, and they resemble the Autoexec.bat files under Microsoft Dos/windows.

The following details the use and difference of BASHRC and profile:

For individual users

. BASHRC

# ~/.bashrc:executed by Bash (1) for non-login shells.
. Profile

# ~/.profile:executed by bourne-compatible login shells.
For all users

http://www.1.qixoo.com/etc/bash.bashrc# system-wide. bashrc file for interactive bash (1) shells./etc/profile#/etc/ Profile:system-wide. profile file for the Bourne shell (SH (1)
Differences in BASHRC and profile

As you can see from the English description above, the difference between BASHRC and profile is:

1. BASHRC is automatically run when the system is booted.

2. Profile is not run until the user logs on.

3. After setting up, you can update the BASHRC using the source BASHRC command, or you can update the profile with the source Profile command.

PS: Usually we modify BASHRC, some distributions of Linux are not necessarily profile this file

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

Supplemental information

In addition, additional instructions are required to introduce several documents related to BASHRC:

~/.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.

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

~/.bash_profile is interactive, login way into bash run, ~/.BASHRC is interactive non-login way into bash run, usually the two settings are roughly the same, so the former will usually call the latter.

Uses and differences for Linux BASHRC and profiles

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.