zer0stimulus
zer0stimulus

Reputation: 23606

Ubuntu: how to look up source code for a utility?

How do I look up the source code for a utility which has a different name from its parent package?

For example, I would like to look up: /usr/bin/sort

Upvotes: 2

Views: 718

Answers (3)

sarnold
sarnold

Reputation: 104020

The apt-get source command will download the Ubuntu packaging and source for you:

$ dpkg -S /usr/bin/sort
coreutils: /usr/bin/sort
$ cd /tmp
$ apt-get source coreutils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Need to get 10.8 MB of source archives.
Get:1 http://us.archive.ubuntu.com/ubuntu/ natty/main coreutils 8.5-1ubuntu6 (dsc) [1,955 B]
Get:2 http://us.archive.ubuntu.com/ubuntu/ natty/main coreutils 8.5-1ubuntu6 (tar) [10.7 MB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ natty/main coreutils 8.5-1ubuntu6 (diff) [23.3 kB]
Fetched 10.8 MB in 6s (1,731 kB/s)                                                   
dpkg-source: info: extracting coreutils in coreutils-8.5
dpkg-source: info: unpacking coreutils_8.5.orig.tar.gz
dpkg-source: info: applying coreutils_8.5-1ubuntu6.diff.gz
$ 

Now the coreutils-8.5 directory contains the patched sources, ready for rebuilding with debuild(1), and the coreutils_8.5.orig.tar.gz contains the original upstream source, if you want to work with that instead of the the patched sources.

Upvotes: 4

fghj
fghj

Reputation: 9394

you can run

dpkg -S /usr/bin/sort

to get name of package, then see package info, get url go to its site and get source code.

Upvotes: 3

DigitalRoss
DigitalRoss

Reputation: 146043

Run the program with --version or --help or read the man page credits or copyright statement and you may find out that it's a GNU project utility. In any case, it will give you enough search terms to locate it. (You can find the man page on line even if you aren't running the OS nearby.)

In the case of your /usr/bin/sort example, this would prompt a search for "gnu coreutils" which will return this gnu site as the top result.

Upvotes: 3

Related Questions