Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-13-2012, 08:24 AM   #1
LQ Newbie
Registered: Jun 2012
Posts: 5

Rep: Reputation: Disabled
Linux command execution flow

I wanted to know the flow of operations that takes place when a command is executed on shell. I guess that shell does a fork-exec. I need a little more elaboration.

Old 06-13-2012, 08:31 AM   #2
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
For the most part commands are forked from the shell. You can even start a new shell which is forked from the original. When the command completes or exits it returns to the original shell.

You can use "exec <command>" to exec a command rather than fork it. However since the exec tells the command to replace the original process (the shell) it means once the command completes it will exit the system. This is sometimes desirable if say you've created a login specifically for the purpose of launching a command and don't want users to access the shell directly. (In such a case you also have to disable traps to insure the user can't hit ctrl-c or some other break/exit keystroke combination fast enough to get to shell prompt before the exec runs.)
1 members found this post helpful.
Old 06-14-2012, 08:04 AM   #3
LQ Newbie
Registered: Jun 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thank you!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Remote command execution via SSH and newgrp command SuperMegaMau Linux - General 4 05-13-2011 08:31 AM
command execution vaalu Linux - Newbie 4 08-23-2010 10:06 AM
Only execute 2nd command on successufl execution of 1st command kregec05 Linux - Newbie 3 08-19-2009 11:29 AM
command execution leonidas Linux - General 1 09-22-2004 01:29 AM
could not open session problem in linux during su - command execution selvaraju Linux - Security 2 08-21-2004 12:24 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:11 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration