如何找到linux命令的源代码

来源:互联网 发布:黑客python编程之道 编辑:程序博客网 时间:2024/05/16 12:11

比如想找到ls, cat, grep, less等这些工具的源代码观摩学习一下,虽然google一下什么都能找到,但使用软件包管理工具则更为方便。以cat的源代码为例:
[whb@jcwkyl keyan]$ which cat
/bin/cat
[whb@jcwkyl keyan]$ rpm -qif /bin/cat
Name       :coreutils                   Relocations: (not relocatable)
Version     :5.97                             Vendor: CentOS
Release     :14.el5                       Build Date: Sat 24 May 2008 11:19:56 PM CST
Install Date: Tue 03 Nov 2009 03:18:40 AM CST      Build Host: builder10.centos.org
Group      : System Environment/Base       SourceRPM: coreutils-5.97-14.el5.src.rpm
Size       :9021731                         License: GPLv2+
Signature   : DSA/SHA1, Sun 15 Jun 2008 07:29:51 AM CST, Key ID a8a447dce8562897
URL         : http://www.gnu.org/software/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.
由上可以看到cat是coreutils中的一个工具。它的主页在http://www.gnu.org/software/coreutils/,于是可以去这个地址下载到coreutils的源代码,然后在其中找到cat
命令的源码。或者去google code上搜索一下cat coreutils。
另外:rpm的命令行参数在它的man文档中有非常清晰的归类,共有query, verify, install, upgrade, remove五大类,每一类操作提供的选项也非常明白。

原创粉丝点击