Use of exec command in linux bash shell
In this article we will look at the usage of exec command in linux.

exec overrides the parent process and replaces it.
Lets see an example to understand exec command usage.
Usage of exec Command
### Check current process id. [root@ngelinux ~]# ps $$ PID TTY STAT TIME COMMAND 5184 pts/1 Ss 0:00 -bash ### Run a command with exec ### It will now replace the new process with current process. ### As a result, our bash pid is overridden and killed by new process. [root@ngelinux ~]# exec echo "hello how are you" hello how are you Connection closing...Socket close. Connection closed by foreign host. Disconnected from remote host(nglinux) at 15:06:57.
Similarly in shell scripts, exec replaces the parent process and can run independently.