Where do you download Linux source code?

Say I'm interested in a source for one specific Linux utility, such as factor . Where can I find the source code for this utility?

+6
linux
source share
8 answers

What I did is type

 man factor 

and went down and found "GNU coreutils 6.10". So, I googled 'coreutils' and ... found a joschi site just linked to.

+9
source share

You can also find out which package uses the binary code downloaded by the package source code.

In Debian (and Ubuntu and something else that is based on Debian) you do this:

  $ dpkg -S / usr / bin / factor
 coreutils: / usr / bin / factor
 $ apt-get source coreutils

The first command will check which package contains the file you are looking for (use " which factor " to find out which of the binaries is executed when you simply type " factor ").

The second command will download and unpack the source files (including the fixes used to build the package) into the current directory, so it must be executed in a specialized or temporary directory.

I am sure that rpm -distributed distributions have a similar mechanism, but I do not know their commands.

+14
source share

To find the package from which the binary comes from, on an rpm-based system, you can enter:

  $ rpm -qf / usr / bin / factor

which will output the name of the package. Instead of this:

  $ rpm -qif / usr / bin / factor

You will also receive information about the package, including its homepage in many cases.

The rpms source also exists, but how to get them depends on the high-level package manager used on top of RPM (yum, urpmi, apt-get4 for rpm, ...).

On most systems, / usr / share / doc / also contains some documentation for the program, and a link to the site is quite common somewhere, possibly in README.

+5
source share

You will usually find the source code on the program’s website if it is open source. In this case, here , since the factor is part of coreutils.

+4
source share

In Gentoo, just look at the ebuild that you compiled with: D.

If you are not sure?

  # which factor 
     / usr / bin / factor
     # grep '/ usr / bin / factor' / var / db / pkg / * / * / CONTENTS
     /var/db/pkg/sys-apps/coreutils-6.12-r2/CONTENTS:obj / usr / bin / factor 5aaf903daa4345efb11618b3cb47e9a5 1224224574
     /var/db/pkg/sys-apps/coreutils-6.12-r2/CONTENTS:obj /usr/lib64/debug/usr/bin/factor.debug 517d965636850633e9b15926dde8c222 1224224575
     # cat /var/db/pkg/sys-apps/coreutils-6.12-r2/SRC_URI
     ftp://alpha.gnu.org/gnu/coreutils/coreutils-6.12.tar.lzma mirror: //gnu/coreutils/coreutils-6.12.tar.lzma mirror: //gentoo/coreutils-6.12.tar.lzma mirror : //gentoo/coreutils-6.12-patches-1.0.tar.lzma http://dev.gentoo.org/~vapier/dist/coreutils-6.12-patches-1.0.tar.lzma
     # cat /var/db/pkg/sys-apps/coreutils-6.12-r2/HOMEPAGE
     http://www.gnu.org/software/coreutils/

But of course, the source code is probably still available at /usr/portage/distfiles .

+3
source share

Another, very good approach is to use Google Code Search . For example, searching for factor coreutils (see the man page or factor --help to see that it is from coreutils), came up with the package as a second result. In two clicks I was browsing factor.c on the Internet.

Google Code Search searches for most open source codes. You can use regular expressions and many advanced search options, including language and license restrictions.

+3
source share

I usually find a link to the source, homepage and other useful information when searching freshmeat .

+2
source share

You can check SourceForge.net .

-one
source share

All Articles