Bash : Interpreter, compiler
configuration file, the scope of effective, there are two categories:
Global configuration:
/etc/profile,/etc/profile.d/*.sh
/etc/bashrc
Personal configuration:
~/.bash_profile
~/.bashrc
By function, there are two categories:
Profile classes: For interactive logins Shell Provide configuration
/etc/profile,/etc/profile.d/*.sh
~/.bash_profile
Function:
(1) Define environment variables, such as PATH,PS1
(2) Run a command or script
BASHRC class: For non-interactive logins Shell Provide configuration
/etc/bashrc
~/.bashrc
Function:
(1) define command aliases;
(2) define local variables;
Variables: Memory space, variable name
Type:
Environment variables: scope Current Shell process and its child processes
Local Variables: scope current Shell Process
Local Variables: The scope is only the current Shell a piece of code in the process ( typically a function context )
How variables are defined:
Bash built-in variables: can be called directly, built in a number of environment variables, such as PATH wait
Custom variables:
variable Assignment: variable name = value
Bash Weak type:
When a variable stores data, it is written by default, and any variable can be directly referenced without being declared;
- : 24bits
120:8bits
To define a local variable:
Name=value
View: Set
Define Environment variables:
Export Name=value
Declare-x Name=value
View: env, printenv, export
Undo Variable:
unset name
Reference variable:
${name}, $name
Bash the reference symbol in:
"': strong references, variable substitution does not occur
"" : Weak references
``: Command Reference
Shell Login Type:
Interactive login:
Login directly through the terminal;
through su-l Username User Switching of the command implementation;
Non-interactive logon:
A command-line window opens under the graphical interface;
Execute the script;
Su Username;
Configuration file Action Order:
Interactive login:
/etc/profile-->/etc/profile.d/*.sh---~/.bash_profile, ~/.BASHRC--/ETC/BASHRC
Non-interactive logon:
~/.BASHRC-->/ETC/BASHRC--/etc/profile.d/*.sh
How does the new configuration of the Edit profile definition take effect?
(1) re- login;
(2) let the current Shell process to re-read the specified configuration file;
Source/path/to/somefile
. /path/to/somefile
Note: Side effects
Marco Linux Learning Notes (bash variable configuration)