I am a newbie in linux and using ubuntu as my desktop os. Most of the time I feel the need to look at the code of the utility like ls, rm etc. Can anyone tell me how to get the code for these utilities.

Currently I am looking for the implementation of ssh-copy-id utility.

2 Answers 2


You can fetch the source of a package with:

apt-get source [package]

Make sure you have the deb-src lines in /etc/apt/sources.list generally, copying the deb lines and changing deb to deb-src is enough.

If you don't know the name of the package with the file in question, you can get that info with apt-file. However, I can't remember how off the top of my head. I recommend reading the docs. :)

  • Thanks, that was helpful. But I have one doubt, I want to retrieve the code of ssh-copy-id, the command exists but apt-get source ssh-copy-id fails to find the code. Any help would be appreciated.
    – hue
    Apr 20, 2011 at 6:07
  • ssh-copy-id is the name of the command, not the name of the package.I have updated my answer.
    – Richo
    Apr 20, 2011 at 6:39
  • ssh-copy-id is shell script. It is it's source code :) Apr 21, 2011 at 7:54

First use dpkg -S to find what package the binary belongs to e.g:

dpkg -S /bin/ls

this will output a line like

coreutils: /bin/ls

This means that coreutils is the package that /bin/ls belongs to. Now use apt-get to fetch source of that package

sudo apt-get source coreutils

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy