LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-11-2012, 02:30 PM   #1
Love@Nagpur
LQ Newbie
 
Registered: Aug 2012
Posts: 4

Rep: Reputation: Disabled
Question Is it possible to see the actual code of the linux command?


Hi All,

I would like to see the actual code which is executed when we give the command to the shell.

e.g. $ls -l

where the ls stored?

how shell know to execute the code of ls file when it gets the ls command in the shell prompt? is there any data structure managed by LINUX/UNIX for the command and respective executable file mapping?



Please help me to understand this basic concepts...

Thanks in advance
 
Old 08-11-2012, 02:33 PM   #2
fl0
Member
 
Registered: May 2010
Location: Germany
Distribution: Slackware
Posts: 105

Rep: Reputation: 34
Hi,

hm ist strace what you want?

Code:
strace -f ls -l
regards fl0
 
1 members found this post helpful.
Old 08-11-2012, 09:46 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,272
Blog Entries: 28

Rep: Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124Reputation: 6124
Quote:
where the ls stored?
ls is a command--a program, in this case to display or list the files in a directory.

The directory in which ls is stored is commonly in your default path in almost every Linux distro. The command

Code:
whereis ls
will tell you where ls resides on your computer.

You can learn more about path statements here: http://www.cyberciti.biz/faq/howto-print-path-variable/

Path statements are also used in Windows.

Hope this helps a bit.

Last edited by frankbell; 08-11-2012 at 09:47 PM.
 
1 members found this post helpful.
Old 08-11-2012, 10:32 PM   #4
Love@Nagpur
LQ Newbie
 
Registered: Aug 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Is there any mapping table which helps to the shell

Thanks for your reply....
I am still confused with the second concept..i.e.
Is there any data structure like maps the command to the particular file..
How shell understand which file is to be executed when it gets the command..?

Please help me...
Thanks in advance
 
Old 08-12-2012, 05:41 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
When you enter a command, the shell looks in the PATH global variable to find where to look. You can always bypass this behavior by specifying the full path.

The PATH variable is set in your startup scripts and can be viewed using "echo $PATH".

As far as seeing the "actual code", you can get the source code from the package maintainer. (start with Sourceforge)
 
Old 08-12-2012, 12:12 PM   #6
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,939

Rep: Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619
I tend to use the find command.

Many commands have help in one way or the other.

The man command is a manual (book) so you type man find and get simple help for that command in shell.

find --h sometimes works too.
 
Old 08-31-2012, 07:15 AM   #7
Love@Nagpur
LQ Newbie
 
Registered: Aug 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks

Thanks for your reply...
 
  


Reply


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
command source code in Linux widapol Programming 5 10-14-2010 03:47 PM
In Vim, : is viewed as command even in actual document? violagirl23 Linux - Software 6 01-07-2008 07:47 PM
LXer: Transform UML model into actual Java source code LXer Syndicated Linux News 0 05-30-2007 11:03 PM
where is the actual code for C functions? like printf, scanf, etc purpleburple Programming 5 06-23-2006 04:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:37 AM.

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