Updated: 11/16/2019 by Computer Hope

Exec may refer to any of the following:

Fictional Execute key in place of the Enter key on a keyboard.

1. With a command line, like Linux or Unix, exec is a BOURNE and POSIX (portable operating system interface for Unix) shell command that replaces the current shell process with the command after exec. This command does not create a new PID (product identification). For example, if you were to run exec <command>, the shell would be replaced by that command. When that command is exited, the shell will exit.


If you're trying to execute a script or program, type ./ in front of the script or program; don't use "exec."

2. With a programming or scripting language, such as C, Perl, or PHP (PHP: Hypertext Preprocessor), exec is a function that executes a program. For example, in Perl, you could use the following line to print the files in the current directory on a Linux system.

exec "ls"

3. With an SSI (server-side include), the exec command executes a command on the server and displays the output to the web page. For example, if we wanted to display the same output used in the above example on a web page using SSI, you could use a command similar to the following example.

<!--#exec cmd="ls"-->

Command, Execute, Fork, PID, Programming terms