Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Apr 20 '11 at 11:00

This question came from our site for professional and enthusiast programmers.

2 Answers 2

This is best asked on superuser, however:

You can fetch the source of a package with :

apt-get source [package]

EDIT:

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.

EDIT AGAIN:

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 :)

share|improve this answer
    
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 '11 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 '11 at 6:39
    
ssh-copy-id is shell script. It is it's source code :) –  Marko Kevac Apr 21 '11 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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.