View Full Version : Source code of man, ls, cat, wc, etc where?

November 30th, 2007, 07:54 PM
H! i am learning C i it would be great if i can find the source code of all the common UNIX commands like cat, ls, pssswd, whereis, etc,etc Anyone knows where i can find this?
Thanks in advance!

November 30th, 2007, 09:29 PM
$ dpkg -S `which cat`
coreutils: /bin/cat
$ apt-get source coreutils

November 30th, 2007, 10:04 PM
A good exercise would be actually writing your own versions of cat, wc, etc. :)

February 28th, 2008, 05:55 PM
$ dpkg -S `which cat`
coreutils: /bin/cat
$ apt-get source coreutils

Then how do i view it.
were doses this put the source code

February 28th, 2008, 06:40 PM
i figured it out

October 25th, 2009, 08:53 AM
You posted "i figured it out". Please post what you figured out. Answers like "i figured it out" doesn't help others when they read the thread.

"apt-get sources (package)" downloads the source of the package to the current working directory.

You should get something like below.

george@georgenotebook:~/temp$ sudo apt-get source coreutils
Reading package lists... Done
Building dependency tree
Reading state information... Done
Need to get 9,729kB of source archives.
Get:1 http://mirror.anl.gov karmic/main coreutils 7.4-2ubuntu1 (dsc) [1,244B]
Get:2 http://mirror.anl.gov karmic/main coreutils 7.4-2ubuntu1 (tar) [9,709kB]
Get:3 http://mirror.anl.gov karmic/main coreutils 7.4-2ubuntu1 (diff) [19.2kB]
Fetched 9,729kB in 1s (5,825kB/s)
gpgv: Signature made Tue 06 Oct 2009 05:24:17 AM CDT using DSA key ID 5E0577F2
gpgv: Can't check signature: public key not found
dpkg-source: warning: failed to verify signature on ./coreutils_7.4-2ubuntu1.dsc
dpkg-source: info: extracting coreutils in coreutils-7.4
dpkg-source: info: unpacking coreutils_7.4.orig.tar.gz
dpkg-source: info: applying coreutils_7.4-2ubuntu1.diff.gz

george@georgenotebook:~/temp$ ls
coreutils-7.4 coreutils_7.4-2ubuntu1.dsc
coreutils_7.4-2ubuntu1.diff.gz coreutils_7.4.orig.tar.gz

October 25th, 2009, 06:14 PM
If you look at the date on the thread, you will see it is from Feb 2008. The people that participated in the thread may be long gone, or the information may be out of date. You would probably be better off creating a new thread.

This thread is closed.