Linux command execution process

When we execute a command, the entire command execution process is as follows:

1, the path is determined

Determining whether the user as to the absolute or relative path input command (e.g., / bin / ls), and if so, direct execution.

2, check aliases

Linux system checks the command entered by the user is "alias command." You know, by the alias command is a command to an existing custom aliases, which uses a custom command name to replace the original command name.

3, it is determined that the user input command internal or external command

Linux command line interpreter (also known as Shell) determines the command input by the user is internal or external command command. Wherein the internal command refers to an internal command interpreter, is directly executed; command the user input is usually an external command, the command processing continues to step four.
An internal command, can be read as the system boot by Shell comes directly from memory; only the external commands in the system with a corresponding executable file, the file needs to read when executed.
Determine a command is an internal command or external command, you can use the type command.

4, an internal command executed directly, outside and check if cached

5, detection of the PATH, there is executed, no error.
In fact executed outside the command will be saved in the internal cache, when executing the same command again, it will take adjustment is performed by the cache, which means not search the PATH

Guess you like

Origin www.cnblogs.com/liuzgg/p/11801538.html