[rhn-users] Newbie Question - What is actually executing the binary?

Corné Beerse cbeerse at lycos.nl
Mon Jun 7 08:18:50 UTC 2004


jludwig wrote:
> On Sat, 2004-06-05 at 21:52, snodx at hotmail.com wrote:
> 
>>Hi list,
>>
>>I am a newbie here (totally new to Information Technology) you could 
>>say.

Do you follow a cource somewhere or is this list 'somewhere'?
Try to find a decent unix or linux based cource. (i.e. no M$Windows based cource)

>>
>>I have studied a bit about Linux, but I am not getting the awnser to
>>this question, infact you could say that all the keyword combinations
>>I have tried so far in Google are not yielding any results.

I got my basics from A.Tanenbaums book on OperatingSystems. Roughly the same 
book as from which Linus build Linux. By head, it is published by 
AcademicServices. If you scan for 'minix', you will find pointers.

>>
>>Here is the question, any thing that I type on Redhat's command terminal,
>>where is the command terminal actually sending it to? For eg if I
>>type say "ls -l" what is actually executing the "ls" binary in the
>>back-end? Which is the software program that is opening the "ls"
>>binary executable file, traversing through the binary instructions
>>in this file, understanding it and executing it?
> 
> 
> 1) All operating systems have a kernel (the kernel is the operating
>    system, linux2.4.xxx, command.com, etc)

Correction, command.com (and cmd.exe) are shells and belong in the next list. 
The M$WindowsNT kernel is called ntoskrnl.exe

> 
> 2) The shell is the command interpreter (bash, tsh, msdos, drdos, etc) 
> 
> 
>>What I am getting out of Linux books is that there is a shell which is
>>interacting with the user and there is the kernel which is actually
>>executing the instructions but I want to know more. Which kernel
>>program is recieving the instructions from the shell?
>>
> 
> There is a program ls (in /bin).
> 
> When the command in typed in <ls -l> the command interpreter (the
> default for Linux is bash) reads the input (command 'ls' and the
> arguments '-l' ). It then locates the command and (if found, it must
> exist and be in your path) executes that command and feeds the command
> any arguments.

In a little more detail it goes as follows:

Typing a command at the prompt is asking the running shell to do something. Most 
shells have basic commands like `ls` build in and hence just jump to the 
routine, do the job and provide the next prompt.

If there is no build-in command, then the "$PATH" is walked, searching for an 
executable with the name of the command. If that is found, this executable is 
exected: The machic number from the file is read (see `man file` for some 
details) If this magic says it is a binary of some sort, executable by the 
current architecture, the kernel is asked to do so.

If this magic says it is a script (the first 2 characters are #! ) then the 
remainder of the first line is executed (search the executable, note the 
recursion) and that gets the remainder of the file at its stdin.

btw: in the above, everything after finding the executable file is handled by 
the kernel by means of the `system()`, `fork()` and/or `exec()` calls.


CBee

> 
>>Sorry for this dumb question. I did'nt where else to post it.
>>
> 
> 
> The only dump question is the one not asked.
> 
>>SNODX
> 
> ______________________________________________
> 
>>rhn-users mailing list
>>rhn-users at redhat.com
>>https://www.redhat.com/mailman/listinfo/rhn-users
> 
> 
> (This is stuff I haven't dealt with for years is I it mess up let me
> know.)






More information about the rhn-users mailing list