How to Get Source Code of a Linux Command on CentOS

1)     Take the strace command for example, first, getwhere the command is in:

[liqingxu@localhoststrace-4.5.19]$ which strace

/usr/bin/strace

2)     Then, get which package this command is in.

[liqingxu@localhoststrace-4.5.19]$ rpm -qf /usr/bin/strace

strace-4.5.19-1.17.el6.x86_64

3)     Go to http://vault.centos.org/6.5/os/Source/SPackages/,get the strace-4.5.19-1.17.el6.src.rpm file.

[liqingxu@localhostDownloads]$ wgethttp://vault.centos.org/6.5/os/Source/SPackages/strace-4.5.19-1.17.el6.src.rpm

--2014-07-2401:50:55--  http://vault.centos.org/6.5/os/Source/SPackages/strace-4.5.19-1.17.el6.src.rpm

Resolvingvault.centos.org... 216.151.172.58

Connecting tovault.centos.org|216.151.172.58|:80... connected.

HTTP requestsent, awaiting response... 200 OK

Length: 533582(521K) [application/x-rpm]

Saving to:“strace-4.5.19-1.17.el6.src.rpm”

 

100%[===============================================================================>]533,582    56.7K/s   in 11s

 

2014-07-2401:51:12 (48.1 KB/s) - “strace-4.5.19-1.17.el6.src.rpm” saved [533582/533582]

4)     To compile this package, you need to install therpmbuild package file.

Switch to root,

yum installrpm-build

 

5)     Then, switch back to a normal user,

mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

 

6)     Then, compile but don’t remove source filesafter buiding.

rpmbuild --recompilestrace-4.5.19-1.17.el6.src.rpm

7)     Then, in ~/ rpmbuild/BUILD/strace-4.5.19, youcan find all source files and the built strace executable.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值