The uses and differences between Linux bashrc and profile

  
 

After using the terminal ssh to log in to the console of LinuxOS
, a prompt symbol (for example: # or ~) will appear. After this prompt symbol, you can enter the command. Linux will do according to the input command. In response, this series of actions is handled by a so-called shell.

Shell is a program, the most commonly used is Bash, which is the shell that the login system will use by default.

bashrc and profile are the shell startup settings file (in fact, these two files are also shell scripts), you can initialize the environment variables for the current shell, etc., they are similar to Microsoft DOS/Windows
The autoexec.bat file.

The following is a detailed description of the uses and differences between 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
/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)

bashrc and profile differences

from above The description shows that the difference between bashrc and profile is:

1. bashrc will run automatically after the system is started.

2. The profile will not run until the user logs in.

3. After setting, you can use the source bashrc command to update bashrc, or use the source profile command to update the profile.

PS: Usually we modify bashrc, some Linux distributions do not necessarily have a profile. File

4. Variables set in /etc/profile (global) can be applied to any user, and variables set in ~/.bashrc etc. (local) can only be inherited in /etc/profile of Quantity, they are & rdquo; father and son & rdquo; relationship.

Additional introduction

In addition, you need to add a few notes about bashrc related documents:

~/.bash_profile: This file can be used by the user to enter the shell information that is used exclusively by the user. When the user logs in, the file is only executed once! By default, he sets some environment variables and executes the user's .bashrc file.

~/.bash_logout: Execute the file each time you quit the system (exit the bash shell).

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

Copyright © Windows knowledge All Rights Reserved