Linux Bash Environment configuration
The environment configuration can be divided into the following: variable type and scope, variable name (definition), configuration file understanding, Undo variable, view (definition) variable, shell login type and configuration file order of action
1. Variable type and scope of action
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:
$? Previous command execution status return value
Number of $# parameters
$* parameter list
[Email protected] parameter list
The $ A command itself, the script itself
2. Variable naming (definition)
Variable naming follows the following rules:
--can only contain letters, numbers, and underscores, and cannot start with a number,
--should not duplicate the existing environment variables in the system
--See the meaning of the name
Variable assignment: variable name = value
such as: Var_name=value equal to both sides can not have spaces
[Email protected] ~]# My=wei
[Email protected] ~]# echo $my
Wei
Note: The relationship between variables and quotation marks:
Single quote ': Strong reference, variable substitution does not occur
Double quote "": Make special symbols effective
Anti-quote ': Reference command
Example:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/8C/wKioL1XmknCBLXVPAAEldvysFlw084.jpg "title=" Figure 33.jpg "alt=" Wkiol1xmkncblxvpaaeldvysflw084.jpg "/>
3. Configuration file Understanding
Divided by range:
Global configuration:
/etc/profile,/etc/profile.d/*.sh
/etc/bashrc
Personal configuration:
~/.bash_profile
~/.bashrc
Classification by functional Category:
Profile class: Provides configuration for the interactive logon shell
/etc/profile,/etc/profile.d/*.sh
~/.bash_profile
BASHRC class: Provides configuration for non-interactive logon shell
/etc/bashrc
~/.bashrc
4. Undo Variables
unset name
[Email protected] ~]# unset my
[Email protected] ~]# echo $my
[Email protected] ~]#
Note: Execution status return code (0-255): 0 is correct; 1-255: Error execution 1,2,127 system reservation, special meaning
5. View (define) variables
View Local Variables: Set
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/8F/wKiom1XmkB-C8NegAAKvI4xquiE101.jpg "title=" Figure 30.jpg "alt=" Wkiom1xmkb-c8negaakvi4xquie101.jpg "/>
Define environment variables: Export name=value or Declare-x Name=value
Example: Export path= $PATH:/usr/local/apsch/bin
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/8C/wKioL1XmkmHSB9LkAADjXPRH5Mo433.jpg "title=" Figure 32.jpg "alt=" Wkiol1xmkmhsb9lkaadjxprh5mo433.jpg "/>
View environment variables: env, PRINTENV, export
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/8F/wKiom1XmkC-RjbVXAAWHq9apfNk312.jpg "title=" Figure 31.jpg "alt=" Wkiom1xmkc-rjbvxaawhq9apfnk312.jpg "/>
6. Shell login type and configuration file action order
Shell Logon type action order:
Interactive login:/etc/profile--/etc/profile.d/*.sh---~/.bash_profile--~/.BASHRC---/ETC/BASHRC
Login directly through the terminal;
User Switching implemented by su-l username command;
Non-interactive login: ~/.BASHRC-/ETC/BASHRC-/etc/profile.d/*.sh
A command-line window opens under the graphical interface;
Execute the script;
Su Username;
This article is from the "10,000-hour Law" blog, be sure to keep this source http://daisywei.blog.51cto.com/7837970/1690785
Linux Bash Environment configuration