Ask Your Question

How can I read the source code of a Linux command?

asked 2014-03-30 22:48:42 -0500

SDas gravatar image

updated 2014-09-28 15:25:56 -0500

mether gravatar image

I am learning programming in linux environment and working with linux commands. I want to see the c program of the commands of Linux for that what I have to do or how it can be possible. Can anyone help me ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-03-30 23:51:59 -0500

FranciscoD_ gravatar image

If you want to see the source code for open source programs, you need to just look up their websites. All their source codes will be available there. For example, to see the source of the ls command, you can do:

$rpm -qf /usr/bin/ls

$ rpm -qi coreutils
Name        : coreutils
Version     : 8.21
Release     : 21.fc20
Architecture: x86_64
Install Date: Fri 07 Mar 2014 13:43:16 EST
Group       : System Environment/Base
Size        : 14678364
License     : GPLv3+
Signature   : RSA/SHA256, Thu 06 Mar 2014 03:53:08 EST, Key ID 2eb161fa246110c1
Source RPM  : coreutils-8.21-21.fc20.src.rpm
Build Date  : Thu 06 Mar 2014 00:13:27 EST
Build Host  :
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : 
Summary     : A set of basic GNU tools commonly used in shell scripts
Description :
These are the GNU core utilities.  This package is the combination of
the old GNU fileutils, sh-utils, and textutils packages.

Now, check the website mentioned in the output: The source code will be available there for download.

For software that isn't installed on your system, use repoquery instead. For software that isn't in Fedora, you'll have to search the internet.

Please read man rpm and man repoquery for more information on these tools.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-03-30 22:48:42 -0500

Seen: 2,176 times

Last updated: Mar 30 '14