Knowledge Reserve
Shell is the interactive command interpreter, the user does not allow direct access to the kernel and operation, then the shell is such a middleware, he is responsible for the user input commands to do grammar analysis, semantic analysis, determine what to do, what enhancements to the options, the operation of what kind of object, And by itself to draw the kernel boot process, is a user and the kernel agent;
The broad shell contains the GUI and CLI, whereas the narrow shell only refers to the CLI;
Linux supports many shell instances, such as TSH, zsh, and so on, and the most widely used is one instance of bash['s many shells];
Note that the shell itself is a command environment, the shell can naturally nest nesting shell, the default CentOS login after the use of bash, if you continue to enter ZSH in the CLI, then you belong to the environment is-->BASH-->ZSH, Please pay attention to your location OH.
Bash Environment Profile Classification
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/AD/wKioL1Xrr5fiPjW0AAuI-J5yPb4488.bmp "title=" Bash environment. bmp "alt=" Wkiol1xrr5fipjw0aaui-j5ypb4488.bmp "/>
What is a variable?
The variable is essentially a specified area in the memory space, and its data content will change;
The variable name essence is a pointer to the memory space of this data change, then in the command execution or operation, only need to pass the variable name, can call that change of data at any time, very convenient
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/AF/wKioL1XrtS6DZyP7AAjaiLUQhrA339.bmp "title=" 1.bmp " alt= "Wkiol1xrts6dzyp7aajailuqhra339.bmp"/>
Types of variables
In Linux, there are roughly 5 types of variables
Environment variable: The scope is the current shell process and its child shell process
Local variables: Scoped current shell process only
Local variable: Only one code fragment in the current shell process is acting [usually a function context]
location variables: Shaped like $ $ $ etc, mainly for bash scripts to pass parameters
Special variable: $? You can view the execution status of the previous command [ please differentiate between execution results and execution status]
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/B1/wKioL1XrvReh6GFxAAGBoG-BhGo168.jpg "title=" Baidushurufa_2015-9-6_12-2-16.png "alt=" Wkiol1xrvreh6gfxaagbog-bhgo168.jpg "/>
How do I define and undo variables?
As I said before, Bash is an instance of the shell, which is itself a command environment, and he also contains built-in variables that we can see through #man Bash, and can use/variables to quickly find variables;
Since bash is a weak type of programming language, variables can be used without direct use of life, but are empty values;
Defining local Variables
Defining environment variables
Undo Variable
the life cycle of a variable is the current shell process, the process termination variable terminates naturally
How do I reference a variable?
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/B4/wKiom1Xrt_qxSdKqAAFKIYKXZ9M236.jpg "title=" Baidushurufa_2015-9-6_11-49-45.png "alt=" Wkiom1xrt_qxsdkqaafkiykxz9m236.jpg "/>
Export path= "$PATH:/usr/test/bin"
' single quote, strong reference, no variable substitution occurs
"" Double quotes, weak references, variable substitution occurs
Shell login type and bash configuration file order
There are roughly 2 types of shell logins:
-
interactive login
-
log into the system directly via the console, VTY, SSH and other connection methods in the form of input account password;
-
switch users by #su-l username, note that the-L is in login form
Non-interactive Login
A terminal window opened under the GUI interface;
Execute script: script must specify shell at the beginning, script execution will open the shell automatically
Non-parametric switching user via #su username
Bash configuration file Action Order
Interactive Login
Non-interactive Login
How does the edited configuration file take effect?
Re-login can be;
To have the current shell process reread the configuration file
#Source/path
# . /path
Note: There may be side effects, inadvertently read multiple times will be appended, if you can ensure that only read once, you can ignore this side effect
This article is from the "Blue Warehouse" blog, be sure to keep this source http://bluebox.blog.51cto.com/8852456/1691812
[8-30] BASH environment variable Knowledge grooming