Bash preliminary discussion and PATH explanation 1. Understand bash. The shell records the shell provided by the local machine in/etc/shells. These shells are binary executable files. In contrast,/etc/passwd can be used to find the shell started by a fixed user. You can use type to view the alias of the bash command, and use alias to execute the command alias. 1.1shell Variable Function 1.1.1 variable setting rule 1) variable = assignment (variables assigned in the terminal will disappear after the terminal restarts !!!, Because this process ends) 2) The equal sign and double quotation marks cannot be used directly with space characters. If there are spaces, use single quotation marks or double quotation marks to keep the original features: "$ pwd" indicates that the characters in the single quotes of the current path are general characters, which is used to protect spaces and special characters from special explanations by shell: 3) conversion of special characters to general characters can be used. 4) in a single string of commands, you must call other commands to provide information. You can use reverse single quotes ~ Or $ Eg: version = $ (uname-r) then echo $ version5) to add variable content, you can use $ name to accumulate content such as: PATH = "$ PATH ": /home/bin6) This variable needs to be executed by other sub-processes, and export must be used to change the variable to the environment variable. 7) uppercase is the system variable, and lowercase is the user variable 8) use unset to cancel the variable and use PATH = $ PATH:/home/binPATH = "$ PATH":/home/binPATH =$ {PATH}:/home/bin, but the last one is better than the 1.1.2 environment variable function: Note: The Custom variable is that the variables displayed by the set command are only available in the current process, even in sub-processes. Environment variables can be used in sub-processes. 1.2 command alias and history variable 1.2.1 command alias settings: alias, unalias note that alias is directly set in the terminal to be saved in the memory and not written to the file; therefore, opening another terminal does not take effect. 1.3bashshell operating environment 1.3.1 path and command query order command query execution order: 1) execute commands in relative and absolute paths, such as "/bin/ls" or ". /ls (targeted command execution) 2) find this command in alias to execute (ensure that the name can execute the alias) 3) execute by bash built-in (builtin) command 4) run the first command in the order of the variable $ PATH. You can run the type command to find the specific source of a command. You can run the type-a command to find the execution sequence of the command. 1.3.2bash login and welcome information: All the configurations in the/etc/issue,/etc/issue.net,/etc/motd 1.3.3bash environment configuration file should be written after the configuration file is written, can be saved for the next use. Login and non-loginshell Loginshell read two configuration files: (1)/etc/profile: overall system settings. It is recommended that you do not modify them. Different configurations are determined based on the user ID. (2) ~ /. Bash_profile or ~ /. Bash_login or ~ /. Profile: it is a personal setting./etc/profile (loginshell will read) the variables set in this file mainly include: PATH/MAIL/USER/HOSTNAME/HISTSIZE external data called include: /etc/inputrc/etc/profile. d /*. the color of the shBash operation interface, including the language family, alias of ll and ls commands, command alias of vi, and command alias of which. If you need to set some shared command aliases for all users, you can create extension names in this directory. sh file, and write the required data to/etc/sysconfig/i18n ~ /. Bash_profile (loginshell only read) Bash reads the Personal Configuration in sequence after reading the complete body configuration :~ /. Bash_profile ~ /. Bash_login ~ /. Profile (only one of the three files will be read, as described in the previous principles) The following is the loginshell configuration file reading process :~ /. Bashrc (non-loginshell will read) other related configuration files/etc/man. config: Mainly MANPATH ,~ /. Bash_history and ~ /. Bash_logout Note: each time you re-open the terminal,. bashrc will automatically execute once, But. bash_profile will not. Because ~ /. Bash_profile is interactive and login to run bash ~ /. Bashrc enters bash in interactive non-login mode. 2. Detailed description of PATH. From the first part, we know that the reading process of the bash configuration file is/etc/profile ----> ~ /. Bash_profle (~ /. Bash_login )(~ /. Profile ). If you need to set the path available to all users, we can set it in/etc/profile, and vice versa, in the next three files. After setting, restart the terminal or directly use source. filename.