1. About the prompt, special Variables
1) Bash has two levels of prompt. The first-level prompt is often seen when Bash is waiting for command input. The default value is the $ symbol, and PS1 is the variable value. The second-level prompt is displayed when bash requires you to enter more information to execute a command. The default value is> and the variable value is PS2.
2) Bash has some special variables that can control shell to work in different ways. For example, the variable noclobber can prevent a file from being overwritten unexpectedly during the redirection output. The SET command can be used to set whether the noclobber variable is valid or invalid. The SET command has two parameters: one is to specify the ON or OFF option of the variable, and the other is the variable name of the special variable. To enable (valid) A special variable, use the-O option to turn it off (invalid) and use the + O option. For example:
$ Set-O noclobber // enable the noclobber variable
$ Set + O noclobber // enable the noclobber variable
3) The ignoreeof variable is used to prohibit the use of Ctrl + D to exit the shell (CTRL + D is used not only to exit the shell, but also to terminate the user's input directly to the standard output.
$ Set-O ignoreeof
4) The noclobber variable can protect existing files when redirecting the output to prevent accidental overwrite.
5) after the noglob variable is set, shell will not extend some special characters or strings in the file name. Such as character *,? And [] are no longer used as wildcards.
2. About Export
after a user logs on to Linux, the system starts a User Shell. In this shell, you can use shell commands or declare variables, or create and run a shell script Program . when you run the shell script program, the system creates a sub-shell . At this point, there will be two shells in the system, one is the Shell started by the system at login, and the other is the shell created by the system for running the script program. When a script program runs successfully, its script shell is terminated and can be returned to the shell before the script is executed. In this sense, you can have many shells, each shell is derived from a shell (called the parent shell.
The variables defined in the sub-shell are valid only in the sub-shell. If a variable is defined in a shell script program, when the script is running, the defined variable is only a local variable in the script program, and other shells cannot reference it,To change the value of a variable in other shells, you can use the Export command to output the Defined variables. The Export command enables the system to define a copy of this variable when creating a new shell. This process is called variable output.
3. You can put the commands to be executed every time you start bash into the initialization file. The most common commands are alias commands and variable definitions.Each user in the system has a. bash_profile file in the main directory. Bash reads the file every time it starts, and all the commands contained in the file will be executed.
Reference
[1]Http://blog.csdn.net/clozxy/article/details/5652275