2

I often come across interesting Linux commands that make me wonder; what are these commands actually doing?

Yes, they might be 'force-removing dependencies', 'installing programs' and doing lots of other stuff, but I'd like to know how they're doing it.

Looking into the source code seems the right thing to do then, but where am I supposed to get it from?

I suppose they'll be written in C?

EDIT: I'm not talking about packages installed using apt-get. I'm looking for the source code of linux/unix commands.

TellMeWhy
  • 17,964
  • 41
  • 100
  • 142

2 Answers2

4

Syntax: apt-get source command-name

Example: apt-get source netstat

If it cannot find:

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

Olimjon
  • 7,522
3

I think you're talking about GNU/Debian commands. Linux does not have commands. Most Linux distributions use GNU utilities (that's why we should call them 'GNU/Linux') and their own commands (such as Debian's APT system). For example, in Ubuntu, commands such as cp, cd, mv are part of the GNU Core Utilities, which are part of the Ubuntu core (base) system. They are represented by the package coreutils. There is an apt-get paramater that you can use to get packages source code: apt-get source. To get coreutils' source code, use sudo apt-get source coreutils. It's important to know that commands are nothing more than binaries placed in the paths of the PATH environment variable. These binaries are usually written in C. Also note that commands from some other Unix-like systems, even though they have the same names, are not from the GNU project and sometimes have different syntax. This is the case with the BSD's (FreeBSD, OpenBSD, NetBSD) and OSX (based in FreeBSD).

Eduardo Cola
  • 5,876
  • 3
  • 20
  • 33