≡ Menu

Get Source Code for any Linux Command

Question: How do I get source code of any Linux command?

Answer: For Debian family Linux distributions, you can get source code for any Linux commands using one of the two methods mentioned below.

Method 1: Get Source Code Using apt-get

Step 1: Add a Source URI to sources.lst

$ cat /etc/apt/sources.list
deb-src http://ftp.de.debian.org/debian lenny main
$ apt-get update

Step 2: Execute apt-get source to get the source

For example, to get source code for netstat command, do the following:

Syntax: apt-get source command-name

Example: apt-get source netstat

Method 2: Get Source Code from packages.debian.org

If you are not pretty sure about the package name, you can navigate through the ‘Sections’
page here: http://packages.debian.org/stable/

  • Click on the topic of the command you wanted to get the source.
  • Search for the command you are looking for, and click on it.
  • In the right side bar, you will have a link to download source package.

Example: Download the source code of the vim editor

  • Step 1: Go to the listing page of Lenny in packages.debian.org
  • Step 2: Click on the link that says ‘editors’
  • Step 3: Search and go to the vim editor page
  • Step 4: In the right side bar, select and download: vim_7.1.314.orig.tar.gz
Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • Grim February 19, 2010, 2:32 am

    I’d like to see info how to get sources in CentOS and Fedora

  • Athul February 19, 2010, 3:37 am

    I basically use google code search http://www.google.com/codesearch for searching through and finding particular snippets of open source codes. Think that is also good option in addition
    to the above if we just want to analyse some part and dont want to do build it.

  • g-ss February 19, 2010, 6:00 am

    you can always install debian in a virtualbox to get that working

  • Milan Cvejic February 19, 2010, 10:07 am

    You can find package sources for centOS here: http://vault.centos.org/5.2/os/SRPMS/
    Then you need just to install rpms for sources that you want.


    Milan Cvejic

  • jameslee February 20, 2010, 9:06 pm

    please provide for rpm packages also

  • Ramesh Natarajan February 26, 2010, 5:09 pm


    Google code search looks great. Thanks for sharing it.


    Use the method suggested above by Milan to get source code of the rpm packages (which is RedHat based). CentOS is based on RedHat code base.

  • Abhijeet April 10, 2012, 11:03 am

    Worked for thankz maan!!!!!

  • KDG June 30, 2013, 5:55 am

    How can I obtain source codes for ubuntu family apart from code search?

  • leonardo gama February 8, 2014, 9:24 pm

    Thank you!!! You helped me so much!!

  • Edison Ramesh August 12, 2015, 3:19 am

    Is there any other way for download the source for unix wait command