LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Is it possible to see the actual code of the linux command? (https://www.linuxquestions.org/questions/linux-kernel-70/is-it-possible-to-see-the-actual-code-of-the-linux-command-4175421602/)

Love@Nagpur 08-11-2012 02:30 PM

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

fl0 08-11-2012 02:33 PM

Hi,

hm ist strace what you want?

Code:

strace -f ls -l
regards fl0

frankbell 08-11-2012 09:46 PM

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.

Love@Nagpur 08-11-2012 10:32 PM

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

pixellany 08-12-2012 05:41 AM

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)

jefro 08-12-2012 12:12 PM

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.

Love@Nagpur 08-31-2012 07:15 AM

Thanks
 
Thanks for your reply...


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