centos下如何获取某个命令的源代码?
2024-10-20 18:51:22
以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文件夹下即可找到所需要的源代码。
最新文章
- 3. 解析 struts.xml 文件
- log4net 记录日志到sqlserver
- java.util.TimeZone 新加方法 getTimeZone(ZoneId zoneId) 导致的问题
- July 23rd, Week 30th Saturday, 2016
- Android 常用 adb 命令
- 343. Integer Break -- Avota
- iOS 实现脉冲雷达以及动态增减元素 By Swift-感谢分享
- 3GP文件格式研究
- [Math]Divide Two Integers
- Java初认识--Java中的语法结构
- Spring拦截器总结
- linux运维工程师面试题收集
- Flask里面的cookie的基本操作
- git 更新远程分支列表
- 淘宝助理导出的csv文件使用的是什么编码,您猜?
- Dubbo的使用入门
- vue mapbox 地图 demo
- Gym - 101981M:(南京) Mediocre String Problem(回文树+exkmp)
- Java中的权限学习笔记
- html5的离线缓存