To be perfected 、。。
Bash Environment configuration:
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 class: Provides configuration for the interactive logon shell
/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: Provides configuration for non-interactive logon shell
/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 variable: scope current shell process
Local variables: scoped only to a snippet of code in the current shell process (usually a function context)
Position variable: $ $, $
Special variables: $?
How variables are defined:
Bash built-in variables: can be called directly, built in a number of environment variables, such as Path
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;
120: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
Reference symbols in bash:
': Strong reference, variable substitution does not occur
"": Weak reference
": Command Reference
Shell Logon Type:
Interactive login:
Login directly through the terminal;
User Switching implemented by su-l username command;
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--and ~/.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
Problem:
1. Define the aliases that are valid for all uses.
2. What if only the modification of the PATH environment variable takes effect for the root user?
This article is from "I take fleeting chaos" blog, please be sure to keep this source http://tasnrh.blog.51cto.com/4141731/1694471
20150830-linux Bash environment variable customization