Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Processing commands using the POSIX shell

&pagelevel(4)&pagelevel

Apart from the built-in POSIX commands, every command is linked to a file in the POSIX file system. The names of most command files are entered in the directory /usr/bin. The shell variable $PATH contains a list of directories in which commands are searched. When executing a command, the POSIX shell reads the command, searches in the directories contained in $PATH for a file name which is identical to the command name, and executes the command.

In order to execute a command that is not one of its built-in commands, the POSIX shell spawns a new process and waits until that process terminates. It then displays the setting of the shell variable PS1 as a prompt (by default, this is $ for non-privileged users or # for privileged users), which indicates that it is ready to process a new command. If you enter the command date, for example, the current date will immediately be displayed, and the POSIX shell will then issue the prompt so that you can enter a new command.

In the case of a command such as date, the period that elapses between command input and the POSIX shell reporting ready to process a new command is very short. However, this period may be substantially longer when a different command is input, for example when a file is compiled. This is because the POSIX shell does not report until execution of the command has been terminated. In order to avoid having to wait for extended periods at the terminal you can use the special character &. If you terminate command input with this character, the POSIX shell reports immediately with the screen prompt without waiting to terminate execution of the entered command. Commands which are terminated with & are started as background processes which you may leave to run without intervention.