以ls命令为例,其它命令类似:

1.利用which命令获取命令可执行文件的位置:

[root@228 /]# which ls
alias ls='ls --color=auto'
/usr/bin/ls

2.利用rpm命令获取命令所在的安装包:

[root@228 /]# rpm -qif /usr/bin/ls
Name : coreutils
Version : 8.22
Release : 15.el7
Architecture: x86_64
Install Date: Mon 23 Apr 2018 10:04:15 PM CST
Group : System Environment/Base
Size : 14581114
License : GPLv3+
Signature : RSA/SHA256, Wed 25 Nov 2015 10:22:25 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : coreutils-8.22-15.el7.src.rpm
Build Date : Fri 20 Nov 2015 01:36:57 PM CST
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.gnu.org/software/coreutils/
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.

3.利用yumdownloader命令下载对应的源安装包:

[root@228 /]# yumdownloader --source coreutils
Loaded plugins: fastestmirror, langpacks
Enabling updates-source repository
Enabling base-source repository
Enabling extras-source repository
base | 3.6 kB 00:00:00
base-source | 2.9 kB 00:00:00
extras | 3.4 kB 00:00:00
extras-source | 2.9 kB 00:00:00
updates | 3.4 kB 00:00:00
updates-source | 2.9 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
coreutils-8.22-21.el7.src.rpm

4.利用rpm2cpio命令提取源代码,得到源码压缩包(coreutils-8.22.tar.xz):

[root@228 /]# rpm2cpio coreutils-8.22-21.el7.src.rpm | cpio -id
11217 blocks

5.利用xz, tar命令解压即可得命令源代码:

[root@228 /]# xz -d coreutils-8.22.tar.xz
[root@228 /]# tar xvf coreutils-8.22.tar

coreutils-8.22文件夹下即可找到所需要的源代码。

最新文章

  1. 3. 解析 struts.xml 文件
  2. log4net 记录日志到sqlserver
  3. java.util.TimeZone 新加方法 getTimeZone(ZoneId zoneId) 导致的问题
  4. July 23rd, Week 30th Saturday, 2016
  5. Android 常用 adb 命令
  6. 343. Integer Break -- Avota
  7. iOS 实现脉冲雷达以及动态增减元素 By Swift-感谢分享
  8. 3GP文件格式研究
  9. [Math]Divide Two Integers
  10. Java初认识--Java中的语法结构
  11. Spring拦截器总结
  12. linux运维工程师面试题收集
  13. Flask里面的cookie的基本操作
  14. git 更新远程分支列表
  15. 淘宝助理导出的csv文件使用的是什么编码,您猜?
  16. Dubbo的使用入门
  17. vue mapbox 地图 demo
  18. Gym - 101981M:(南京) Mediocre String Problem(回文树+exkmp)
  19. Java中的权限学习笔记
  20. html5的离线缓存

热门文章

  1. Template -「整体二分」
  2. CD 从抓轨到搭建流媒体服务器 —— 以《月临寐乡》为例
  3. P2532 [AHOI2012]【一本通提高组合数学】树屋阶梯
  4. 记一次删除k8s namespace无法删除的问题
  5. while循环和dowhile
  6. python socket理解
  7. 整除分块套杜教筛为什么是 O(n^2/3) 的
  8. Nginx 文件传输效率、实时、压缩配置指令
  9. Redis缓存雪崩、缓存穿透、缓存击穿
  10. Excel 运算符(四):引用运算符