How to get the source code of Linux commands

  
                  

If you want to know more about the Linux system, it is still necessary to be familiar with some of the underlying systems. We can first understand how some Linux commands implement related functions. How do you get the source code of the commands? This article will introduce in detail.

Let's take the source code of the cat command as an example:

rpm -qif `which cat` will display the following information:

-------- -------------------------------------------------- ----------------

Name : coreutils Relocations: (not relocatable)

Version : 5.2.1 Vendor: Red Hat, Inc.< Br>

Release : 31.8.el4_7.1 Build Date: Thursday, October 23, 2008 21:04:08

Install Date: Tuesday, April 07, 2009 10:17:33 Build Host: ls20-bc2-14.build.redhat.com

Group : System Environment /Basic Source RPM: coreutils-5.2.1-31.8.el4_7.1.src.rpm

Size : 7314345 License: GPL

Signature : DSA/SHA1, Monday, October 27, 2008 22:56:59, Key ID 219180cddb42a60e

Packager : Red Hat, Inc. < ;http://bugzilla.redhat.com/bugzilla>

URL : ftp://alpha.gnu.org/gnu/coreutils/

Summary : GNU Core Tools: A set of tools commonly used in shell scripts.

Description :

These are the core tools of GNU. This package is a combination of the old GNUfileutils, sh-utils,

, and textutils packages.

-------------------------------------------- ------------------------------

With the above information, we can know that the cat command is from coreutils -5.2.1-31.8.el4_7.1.src.rpm source package, we can go to ftp://alpha.gnu.org/gnu/coreutils/mentioned above to download tarball, you can also go to rpmfind.net website Go to search coreutils-5.2.1-31.8.el4_7.1.src.rpm to download this source package.

If you download the tar.gz package, then tar zxvf tar.gz package can be;

If you download the src.rpm source package, then:

1, rpm2cpio Coreutils-5.2.1-31.8.el4_7.1.src.rpm

Copyright © Windows knowledge All Rights Reserved