Shell Command Execution 1. shell commands include built-in commands and external commands. Built-in commands are built-in by shell interpreter. They are directly executed by shell and do not need to derive new external commands of the process. These commands are binary code and shell script. 2. www.2cto.com (1) to execute external binary commands, a mechanism is required to allow sub-processes to be converted to commands to be executed. Unix/Linux calls exec to do this. It allows a process to overwrite itself with executable code of other commands. Binary code needs to be loaded into memory by the disk. The shell interpreter calls a copy of fork itself, and then uses the exec series functions to execute External commands, so that the external commands Replace the current fork sub-shell. (2) The execution of shell scripts is slightly different from that of binary files. For shell scripts, the shell interpreter fork a sub-shell program, and the sub-shell program will check the first line of the script (such #! /Bin/bahs), find the interpreter used to execute the script, and then load the interpreter to execute the script program. The program is obviously a sub-process of the current shell. If this interpreter is the same shell as the current shell, such as bash, It is the subshell of the current shell, and all the commands in the script are executed in the subshell environment, does not affect the current shell environment.