Bash's configuration file,
Divide by Range:
Global configuration:
/etc/profile,
/etc/profile.d/*.sh
/etc/bashrc
Personal configuration:
~/.bash_profile
~/.bashrc
by function:
Profile class: Provides configuration for the interactive logon shell
/etc/profile,
/etc/profile.d/*.sh
~/.bash_profile
1, define environment variables, such as Path
2. Run the command or script
BASHRC class: Shell provides configuration for non-interactive logon
/etc/bashrc
~/.bashrc
1, used to provide command aliases
2, defining local variables
Variable: variable name is pointer, point to variable
Type:
Environment variables: The current shell and its child processes
Export Name=value
Declare–x Name=value
Local variables: Current process only
Name = value
Local variables: A snippet of code in the current shell process
Position variable: $1,$2
Special variables: $?
How to define:
Bash built-in variables, without definition, can be called directly. PATH
Custom variables:
Assignment method: Variable name = value
Self-increment: name= "$name dddddd"
Weak type!!! Save as character type by default
Pstree can query the process tree
View environment variables
Env
Printenv
Export
Undo Variable
unset name
Reference variable
$name ${name}
Reference symbol
' Strong reference, variable substitution does not occur
"" Weak reference
"Command reference, the execution result of the reference command
Shell Logon Type:
Interactive: Direct Terminal su-username
Non-interactive: graphical interface su username
Order of action at logon
Interactive:/etc/profile->/etc/profile.d/*.sh-> ~/.bash_profile
The following overrides the previous
Non-interactive:~/.bashrc–>/etc/bashrc–>/etc/profile.d/*.sh
How the new configuration takes effect:
1, re-login
2, reread the configuration file
Source/path/to? Somefile
. /path/to? Somefile
After the experiment, correct:
1. How do I define an alias that is valid for the user you are using?
/ETC/BASHRC I guess it's here to change,
2. What to do if only the modification of the PATH environment variable takes effect for the root user
~/.BASHRC Modify the root of this file
Bash Small Summary