查找linux command source code

 

# rpm -qif `which sort`

 

Name        : coreutils                    Relocations: (not relocatable)

Version     : 5.2.1                             Vendor: CentOS

Release     : 31.4                          Build Date: Sun 13 Aug 2006 10:26:34 AM GMT

Install Date: Sat 17 Mar 2007 07:25:40 AM GMT      Build Host: build-i386

Group       : System Environment/Base       Source RPM: coreutils-5.2.1-31.4.src.rpm

Size        : 7308841                          License: GPL

Signature   : DSA/SHA1, Sun 13 Aug 2006 12:54:58 PM GMT, Key ID a53d0bab443e1821

Packager    : Johnny Hughes <[email protected]>

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

Summary     : The GNU core utilities: a set of 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.

 

 

若是下載的src.rpm源碼包,則:

  1、rpm2cpio coreutils-5.2.1-31.8.el4_7.1.src.rpm| cpio -idv

  2、此時會在當前目錄下產生coreutils-5.2.1.tar.bz2文件

  3、bzip2 -d coreutils-5.2.1.tar.bz2 解壓,會產生coreutils-5.2.1.tar 文件

  4、tar xvf coreutils-5.2.1.tar 此時在當前目錄下將產生coreutils-5.2.1目錄,源碼便在其中。

  進入coreutils-5.2.1目錄,下面的src文件夾便是存放cat命令源代碼的地方,當然了除了cat,linux的很多基礎的外置命令的源代碼都存放其中,像cp,chown,chmod,df,ls,rm,dd等等

  對了,順便說一下,coreutils-5.2.1目錄下的configure腳本有5w多行哦,裏面體現了很多shell的編程技巧,很值得喜歡shell並且想進一步深入學習shell編程的朋友去拜讀一下哦。

 

發佈了41 篇原創文章 · 獲贊 7 · 訪問量 13萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章