Both exec and source belong to the Bash Internal command (builtins commands), where you can view all the internal command information by entering man exec or man source under bash.
The bash shell commands are divided into two categories: external commands and internal commands.
External commands are implemented through system calls or independent programs, such as SED, awk, and so on.
Internal commands are implemented by a special file format (. def), such as CDs, PWD, etc.
Fork is a system call for Linux that is used to create a subprocess (child process).
A child process is a copy of the parent process that obtains a certain resource allocation from the parent process and the environment that inherits the parent process. The only difference between a child process and the parent process is the PID (process ID).
Environment variables (variables passed to child processes, hereditary is the fundamental difference between local variables and environment variables) can only be passed from the parent process to the child process in one direction. Regardless of how the environment variable of the child process changes, the environment variables of the parent process are not affected.
Two methods of executing shell scripts
One is to create a new shell, and then execute the corresponding shell scripts;
The usual script file (. sh) is this usage. This method first enables the new Sub-shell (the new child process) and then executes the command under it.
One is executed under the current shell and no more shells are enabled.
The source command under Linux no longer produces a new shell, but executes all commands under the current shell
exec parsing in Shell under Linux