Latest LQ Deal: Linux Power User Bundle
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 12-17-2006, 07:34 AM   #1
LQ Newbie
Registered: Dec 2006
Posts: 1

Rep: Reputation: 0
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.
Old 12-17-2006, 07:42 AM   #2
Registered: Jan 2003
Distribution: Slackware
Posts: 82

Rep: Reputation: 15
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 Other packages you may be interested in are GNU grep, and procps from
Old 12-17-2006, 07:45 AM   #3
Registered: Jan 2003
Distribution: Slackware
Posts: 82

Rep: Reputation: 15
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
Old 12-17-2006, 07:49 AM   #4
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
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.


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
Viewing source code for linux command mohdniyas Linux - Newbie 10 12-11-2006 10:29 AM
LXer: Voip Encryption, source code open source LXer Syndicated Linux News 0 07-09-2006 03:21 PM
viewing kernel`s source code python302 Programming 3 04-12-2006 01:55 PM
Viewing source code for a program... ksoma Programming 3 02-27-2005 04:05 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:13 PM.

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