以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文件夹下即可找到所需要的源代码。

centos下如何获取某个命令的源代码?的更多相关文章

  1. Centos下运行定时任务Crontab命令介绍

    1.Cron的启动与关闭 因为Cron是Linux的内置服务.能够用下面的方法启动.关闭这个服务: /sbin/service crond start           //启动服务 /sbin/s ...

  2. CentOS下mysql数据库常用命令总结

    mysql数据库使用总结 本文主要记录一些mysql日常使用的命令,供以后查询. 1.更改root密码 mysqladmin -uroot password 'yourpassword' 2.远程登陆 ...

  3. centos 下 apache 重启启动命令

    apache 启动 usr/local/apache243/bin/apachectl start apache 重启 usr/local/apache243/bin/apachectl restar ...

  4. CentOS下mysql数据库常用命令

    1.更改root密码 mysqladmin -uroot password 'yourpassword' 2.远程登陆mysql服务器 mysql -uroot -p -h192.168.137.10 ...

  5. centos下安装ipython(minglnghang命令行)

    下载文件 wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate 执行安装 python get-pip.py 这就安装好了 ...

  6. centos下如何停止ping命令

    ctrl + c 或者 Ctrl + d(好像不行) man ping

  7. linux下自动获取并安装软件包 apt-get 的命令介绍

    apt-cache search package    搜索包 apt-cache show package    获取包的相关信息,如说明.大小.版本等 sudo apt-get install p ...

  8. centos下无法使用lsof命令"-bash: lsof: command not found"

    1.问题描述 : 在CentOS下,使用lsof命令,报错如下: 2.解决方法: #yum install lsof 若输入y不能安装成功,通过yum install 包 -y 进行安装: # yum ...

  9. 转载自php100中文网 centos下lamp 环境搭建

    学习PHP脚本编程语言之前,必须先搭建并熟悉开发环境,开发环境有很多种,例如LAMP.WAMP.MAMP等.这里我介绍一下LAMP环境的搭建,即Linux.Apache.MySQL.PHP环境. 一. ...

随机推荐

  1. 序列化和返序列化的概述和对象的序列化流ObjectOutputStream

    序列化和返序列化的概述 对象的序列化流ObjectOutputStream Person类: package com.yang.Test.ObjectStreamStudy; import java. ...

  2. python subprocess相关操作

    python subprocess常用操作 1.subprocess模块的常用函数 函数 描述 subprocess.run() Python 3.5中新增的函数.执行指定的命令,等待命令执行完成后返 ...

  3. 丽泽普及2022交流赛day18 社论

    A 暴力扫一遍 B 算法 0 似乎是二分 算法 1 随便贪心 C 算法 1 枚举一个点作为最大值 / 最小值,用单调栈维护其作为答案的左右端点即可轻易计算 . 时间复杂度 \(O(n)\) . 算法 ...

  4. javascript 原生class操作

    <script type="text/javascript"> function hasClass(elements, cName) { return elements ...

  5. javascript引用"bug"带来的"继承"

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  6. Taurus.MVC WebAPI 入门开发教程1:框架下载环境配置与运行(含系列目录)。

    前言: Taurus.MVC 微服务版本已经发布了:Taurus.MVC V3.0.3 微服务开源框架发布:让.NET 架构在大并发的演进过程更简单. 以前都是框架发布时写点相关功能点的文章,没有形成 ...

  7. MySQL更新锁表超时 Lock wait timeout exceeded

    背景 最近在做一个订单的钉钉审批功能,钉钉审批通过之后,订单更新审核状态,然后添加一条付款,并且更新付款状态: // 订单审批通过 @Transactional(rollbackFor = Excep ...

  8. Mybatis核心配置文件中的标签介绍

    0. 标签顺序 Mybatis核心配置文件中有很多标签,它们谁谁写在前写在后其实是有顺序要求的: 从前到后: properties?,settings?,typeAliases?,typeHandle ...

  9. HCIA-Datacom 3.4 实验四:实现VLAN间通信实验

    实验介绍: 划分VLAN后,不同VLAN的用户间不能二层互访,这样能起到隔离广播的作用.但实际应用中,不同VLAN的用户又常有互访的需求,此时就需要实现不同VLAN的用户互访,简称VLAN间互访.华为 ...

  10. jsp获取下拉框组件的值

    jsp获取下拉框组件的值 1.首先,写一个带有下拉框的前台页 1 <%@ page language="java" contentType="text/html; ...