以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. 启动docker报错Failed to listen on Docker Socket for the API.

    1.启动时报错查看日志发现 # journalctl -xe Failed to listen on Docker Socket for the API. 查找socket这个配置文件,修改如下 # ...

  2. SpringWeb 拦截器

    前言 spring拦截器能帮我们实现验证是否登陆.验签校验请求是否合法.预先设置数据等功能,那么该如何设置拦截器以及它的原理如何呢,下面将进行简单的介绍 1.设置 HandlerInterceptor ...

  3. 常用的函数式接口_Consumer接口和常用的函数式接口_Consumer接口的默认方法andThen

    Consumer接口 java,util.function.Consumer接口则正好与Supplier接口相反,它不是生产一个数据,而是消费一个数据,其数据类型由泛型决定 抽象方法:accept C ...

  4. Ngnix初步学习

    Nginx下载与安装(Linux) nginx下载 1.root用户下进入/usr/local/src su root cd /usr/local/src 2.下载nginx所需包 # nginx w ...

  5. 有一种密码学专用语言叫做ASN.1

    目录 简介 ASN.1的例子 ASN.1中的内置类型 ASN.1中的限制语法 总结 简介 ASN.1是一种跨平台的数据序列化的接口描述语言.可能很多人没有听说过ASN.1, 但是相信有过跨平台编程经验 ...

  6. PHP goto

    if (true){ echo "run if\n"; goto fly; } else{ fly: echo "run else"; }

  7. beego下让swagger按照更新了controllers的接口信息自动更新commentsRouter_controllers.go

    beego下让swagger按照更新了controllers的接口信息自动更新commentsRouter_controllers.go (1)在beego环境中,当更新了controllers目录下 ...

  8. jQuery基础入门(二)

    jQuery 效果 显示和隐藏 在 jQuery 中可以使用 hide() 和 show() 方法来隐藏和显示 HTML 元素,以及使用 toggle() 方法能够切换 hide() 和 show() ...

  9. Spring源码 19 IOC getBean

    参考源 https://www.bilibili.com/video/BV1tR4y1F75R?spm_id_from=333.337.search-card.all.click https://ww ...

  10. k8s-Pod基础

    制作镜像 第一个pod 搭建Harbor仓库 重启策略 启动命令 pod基本命令 设置环境变量 数据持久化和共享-hostPath 数据持久化和共享-emptyDir JSON格式编写pod文件 Co ...