Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
12-07-2006, 11:16 AM
|
#1
|
LQ Newbie
Registered: Oct 2006
Location: Bangalore
Distribution: Ubuntu
Posts: 7
Rep:
|
Viewing source code for linux command
Hi,
How to view the source code for linux shell commands like cat,ls,date,etc?
I tried to open the file /bin/cat using OpenOffice but many charecters in the file are unintelligible..
I thought i can view the source code in C language..How to view it?
Should we use some other coding than Unicode to view the source code in readable(intelligible) form?
Thanks in advance..
|
|
|
12-07-2006, 11:23 AM
|
#2
|
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450
Rep:
|
Binary files don't have the source code embedded in them (unless they are debugging versions).
Those utilities are part of the coreutils package. You can get the source right from the source (i.e., http://ftp.gnu.org/pub/gnu/coreutils...ls-6.6.tar.bz2). Also, usually your distro will have a source-package corresponding to each binary package. In this case, install the relevant package.
|
|
|
12-07-2006, 11:40 AM
|
#3
|
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530
Rep:
|
What distro are you using?
In Ubuntu and other Debian-based distros you can request the installation of the source code for a given package using the "apt-get source <packagename>" command. This will not work on distros which are not derived from debian. To really help you, we need to know what distro you are using.
Anyhow, going on assumption that you are using Ubuntu, here's what to do to see the code for a specific program.
- Open a Terminal window. The following commands should be typed into the terminal window
- Find out what package the program belongs to:
Code:
dpkg -S /path/to/program/file
In the case of /bin/cat, the package name is "coreutils"
- Getting the source can generate quite a few files (it can be a little messy), so we'll create a sub-directory for them, and change into it:
Code:
mkdir ~/src
cd ~/src
- Now use apt-get to fetch the source:
Code:
apt-get source coreutils
Now you should have the source. It may be in an archive file, or apt-get might have expanded it for you.
Last edited by matthewg42; 12-07-2006 at 11:40 AM.
Reason: typo correction
|
|
|
12-08-2006, 09:14 AM
|
#4
|
LQ Newbie
Registered: Oct 2006
Location: Bangalore
Distribution: Ubuntu
Posts: 7
Original Poster
Rep:
|
I m using ubuntu..
~/src $ apt-get source coreutils
gave me a message like this
Reading package lists...Done
Building dependancy tree..Done
E: you must put some source URIs in your sources.list
What it means? please..
|
|
|
12-08-2006, 09:42 AM
|
#5
|
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530
Rep:
|
Your sources.list file contains a list of repositories from which packages are fetched. Looks like you don't have the source repositories enabled.
You can enable them from the synaptic package manager - go into the repository settings (it's an option from one of the menus), and enable the source repos.
Alternatively, if you post the contents of your /etc/apt/source.list file here (in [code] tags), I can show you how to manually edit the file to enable them.
|
|
|
12-08-2006, 01:21 PM
|
#6
|
LQ Newbie
Registered: Oct 2006
Location: Bangalore
Distribution: Ubuntu
Posts: 7
Original Poster
Rep:
|
Hi,
1.I couldnot find Source Repository settings,to enable it in SynapticPackageManager-->Settings-->Repositories..
2.$/etc/apt/source.list gave me
"Uncomment following two lines to fetch updated software from the network #utuntu site address " kind of messages...
[I m not able to give the entire message here since
I m not able dial up to internet from Ubuntu( Mine is a Huawei wireless modem,which is not being supported by my kernel 2.6.12..I read it is supported by kernel 2.6.18 onwards only)..I have to reboot to MS OS to connect to net..I read of VMWare but i dont know whether my configuration(P4-2.4 GHz, 128Mb RAM)is supported by that..]
|
|
|
12-08-2006, 01:56 PM
|
#7
|
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530
Rep:
|
Which version of Ubuntu do you have? The repository handling in synaptic has change a little over the last few releases. You can find out your release by entering this command:
Code:
grep DISTRIB_DESCRIPTION /etc/lsb*
I have a screenshot from Ubuntu 6.06.1 LTS : http://porpoisehead.net/misc/synap.png
I've highlighted some example entries. Basically, go down the whole list and enable all with "(Source)" next to the name.
If you're running an older version of Synaptic, or for some reason this isn't working, you should edit the /etc/apt/sources.list, and uncomment some of the lines starting with "# deb-src", i.e.
Change this:
Code:
deb http://gb.archive.ubuntu.com/ubuntu/ edgy main restricted universe multiverse
# deb-src http://gb.archive.ubuntu.com/ubuntu/ edgy main restricted universe multiverse
To this:
Code:
deb http://gb.archive.ubuntu.com/ubuntu/ edgy main restricted universe multiverse
deb http://gb.archive.ubuntu.com/ubuntu/ edgy main restricted universe multiverse
Only enable the deb-src lines where the corresponding deb line is not commented out.
|
|
|
12-08-2006, 01:57 PM
|
#8
|
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530
Rep:
|
Oh one more thing. In either case (editing the sources.list or doing it via Synaptic), you need to update repository information before you'll be able to get the sources:
Code:
sudo apt-get update
apt-get source ...
|
|
|
12-11-2006, 09:02 AM
|
#9
|
LQ Newbie
Registered: Oct 2006
Location: Bangalore
Distribution: Ubuntu
Posts: 7
Original Poster
Rep:
|
Mine is Breezy Badger, Ubuntu 5.10...
I edited /etc/apt/sources.list as you told. But again it is asking for source URIs..
Meanwhile i got a CD with MPlayer..
I tried to install it so that i can listen to mp3 songs while working..but i need to downgrade my gcc to version 3 from 4..
Thanks a lot matthew..
|
|
|
12-11-2006, 09:36 AM
|
#10
|
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530
Rep:
|
If the apt-get sources is taking too much effort to configure, don't worry so much about it... I only suggested it because it's more convenient (once configured) than downloading sources manually.
I have found in the past that mplayer is a massive pain in the rear to compile. If you can get binary packages, you'll save yourself a lot of effort.
|
|
|
12-11-2006, 10:29 AM
|
#11
|
LQ Newbie
Registered: Oct 2006
Location: Bangalore
Distribution: Ubuntu
Posts: 7
Original Poster
Rep:
|
Thanks a lot again..Ur quick responses have multiplied my interest in Linux...
|
|
|
All times are GMT -5. The time now is 09:58 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|