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