LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   viewing the source code (https://www.linuxquestions.org/questions/linux-newbie-8/viewing-the-source-code-511309/)

mohsinjavedawan 12-17-2006 07:34 AM

viewing the source code
 
how can i view the source code for the general commands of the shell
for example ls, echo, cat etc

similarly how can i view the source code for standard c functions for example pow, strcpy, strlen.

solnul 12-17-2006 07:42 AM

The standard shell commands are mostly in the GNU packages bash and coreutils. The standard C library is a GNU package called GLIBC. You can find source for these on ftp.gnu.org/gnu. Other packages you may be interested in are GNU grep, and procps from procps.sf.net.

solnul 12-17-2006 07:45 AM

Oh, one other thing. If you use a distro with package management utilities there is a general answer to your problem. You can use look up which package owns a file, then download its source. For example:

For RPM-based (Fedora, Mandrake, SUSE, ...):
rpm -qf /path/to/file

For Debian/Ubuntu:
dpkg --search /path/to/file

jschiwal 12-17-2006 07:49 AM

The commands such as ls and cp are supplied by the coreutils package. Download a source package if you don't have one. The C library is called glibc. You can download the source for that as well. Look at "man <function>" and see which header contains the definition. The source for the function is probably in a directory by the same name, minus the .c.


All times are GMT -5. The time now is 08:15 AM.