Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to study the source code of the standard command line functions in Linux such as ls, echo, cat, etc. But I have been unable to find the source code (a Google search was useless).

Does someone know where it's available? I know it's a naive question but I really can't find this source code.

share|improve this question

closed as not constructive by gnat, Bart van Ingen Schenau, thorsten müller, Robert Harvey, MichaelT Apr 8 '13 at 21:33

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 7 down vote accepted

Those commands are the GNU core utilities. The latest code can be retrieved from a git repository here:

To check it out anonymously use git clone like this:

$ git clone git://
share|improve this answer

There are several implementations of these, the most popular ones being the GNU coreutils (found in most Linux distributions) and the BSD implementation (found in FreeBSD, OS X, and other mostly non-linux Unix-likes).

Unless you are on a distro that installs everything from source (like Gentoo), you will have to ask your package manager to download the sources for you. On Debian-based systems, the appropriate command is apt-get source {package-name}, which downloads the source for the specified package and stores it in the current directory. All that's left is find out which package those commands are in; you can either dig through your package manager's documentation to find out how, or you can search your distro's website - most of them have a package search that allows you to search for individual files within packages.

For Debian-based systems (such as Ubuntu):

$ dpkg -S /bin/rm
coreutils: /bin/rm
$ dpkg -l coreutils
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                         Version                      Description
ii  coreutils                    8.13-3ubuntu3                GNU core utilities

For Red Hat-based systems (such as Fedora and Centos):

$ rpm -qf /bin/rm
share|improve this answer
+1 for "ask the package manager". Some Linux distributions make their own changes to package code that isn't reflected in the base sources from GNU. – Ross Patterson Feb 9 '13 at 22:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.