Linux --- shell --- 1 Command Execution 1. how to execute commands in Shell 1> after you enter a command in the command line, shell will fork and exec the command, except for the built-in commands of Shell, executing a built-in command is equivalent to executing a Shell function and does not create a process. For example: cd/alias/umask/exit... 2> execute the script to write a simple script and save it as script. sh :----------------------------#! /Bin/sh cd .. ls ---------------------------- in the Shell script, use # to indicate the annotation, but if # is at the beginning of the first line and is #! (Shebang) is an exception. It indicates that the script is run with the interpreter/bin/sh specified later. Shell will fork a sub-process and call exec to execute the./script. sh program. The exec system call should replace the code segment of the sub-process with the code segment of the script. sh program and execute it from its _ start. However, script. sh is a text file with no code segment or _ start function. What should I do? In fact, exec has another mechanism. If you want to execute a text file and the first line of the text file is to use Shebang to create an interpreter, the current process is replaced with the interpreter code segment and executed from the interpreter's _ start. The text file is passed to the interpreter as a command line parameter. Therefore, executing the above script is equivalent to executing the program:, $/bin/sh./script. sh