/etc/profile: This file sets the environment information for each user of the system, and the file is executed when the user logs on for the first time.
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.
~/.bash_profile: Each user can use this file to enter shell information dedicated to their own use, when the user logs on, the
The file is only executed once! By default, he sets some environment variables to execute the user's. bashrc file.
~/.BASHRC: This file contains bash information dedicated to your bash shell, and when you log in and each time you open a new shell, the
The file is read.
~/.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 the variables set in ~/.BASHRC, etc. (local) 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 into bash run
Usually the two settings are roughly the same, so the former usually calls the latter.
Settings to take effect: can be restarted to take effect, you can also use the command: source
Alias php=/var/eyouim/pub/php/bin/php
Source /etc/profile
2.3. User Environment Configuration
To make bash better serve us, we need to customize the bash shell environment.
2.3.1. Bash_profile,. BASHRC, and. Bash_logout
The above three files are the user Environment profile for the bash shell, which is located in the user's home directory. The. Bash_profile is the most important configuration file that is read every time a user logs on to the system, and all commands inside it are executed by bash. Profile (used by Bourne Shell and Korn shell) and. Login (used by C shell) ) Two files are synonyms of. Bash_profile to be compatible with other shells. Use the. profile file in Debian instead of the. bash_profile file.
The. bashrc file is read when the bash Shell invokes another bash shell, which is then read when the Bash command is typed in the shell to launch a new shell. This effectively separates the environments required for logins and child shells. But in general, it will be called in. bash_profile. BASHRC scripts for unified configuration of user environments.
The. Bash_logout is read when exiting the shell. So we can put some clean-up orders into this file.
The BASH.BASHRC and profile of the/etc directory are system-level (global) configuration files that are read when the. Bash_profile and. Bashrc\ are not found in the user's home directory. Bash_history is bash The Shell's history file, which records all the commands you entered in the Bash shell. You can use the HISSIZE environment variable to set the number of records saved in the history file. Alias L = ' ls-l ' is the statement that sets the alias, and placing it in these configuration documents allows us to replace the ' ls-l ' command with a simple ' l ' command.
|
|
When we have modified these configurations, we can use the source. Bash_profile command to make its modifications effective immediately. |
2.3.2. Options
The options in the Bash shell control the behavior and functionality of the shell, which we can set with the Shopt command. Using the SET command is also possible, but it has been replaced by shopt, but in order to be backwards compatible, the SET command is still available. Use the shopt command without parameters to list the options that can be set only by shopt in the current shell, with Shopt-o to list the options that can be set by the set command.
The following are some of the basic options that are available by the SET command, which are turned off by default.
Emacs enters Emacs edit mode
VI Enter VI edit mode
Ignoreeof does not allow the use of ctrl_d exit alone, to use exit. Equivalent to ignoreeof=10
Noclobber does not allow redirection to overwrite existing files
Noglob do not allow extended file name wildcard characters
Nounset error when using undefined variables
Here are some options that can be set only by the Shopt command.
Cdspell automatic correction of minor errors in CD command parameters
Hostcomplete the Auto-completion of the hostname by pressing the TAB key at the beginning of the @
Dotgblob file names starting with a point are included in the pathname extension
Mailwarn Display message warning message
The options for the shopt command are as follows:
-P display to set options and current values
-S set each option to ON
-u set each option to off
-Q does not output information
-O
from:http://blog.163.com/wang_hai_fei/blog/static/309020312008728333912/
Differences between. Bash_profile and. BASHRC (how to set it in effect)