RPM 与 DPKG 使用
Posted Li-Yongjun
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RPM 与 DPKG 使用相关的知识,希望对你有一定的参考价值。
前言
在上篇文章中,我们介绍了 RPM 和 DPKG 的由来及其功能。这篇文章,我们着重介绍下这两种软件管理器的使用。
顺藤摸瓜
在嵌入式开发中,我们经常会有研究某个命令源码的需求。比如想知道 ifconfig
的实现原理。
step 1,查找命令所在位置
# whereis ifconfig
ifconfig: /usr/sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz
step 2,查找二进制文件所属的 RPM 包
# rpm -qf /usr/sbin/ifconfig
net-tools-2.0-0.25.20131004git.el7.x86_64
可知,ifconfig 是 net-tools 工具集中的一个子工具。想要分析 ifconfig 源码,只要下载 net-tools 源码就可以了。
进阶
1、查看软件包文件列表
# rpm -ql net-tools
/bin/netstat
/sbin/arp
/sbin/ether-wake
/sbin/ifconfig
/sbin/ipmaddr
/sbin/iptunnel
/sbin/mii-diag
/sbin/mii-tool
/sbin/nameif
/sbin/plipconfig
/sbin/route
/sbin/slattach
/usr/lib/systemd/system/arp-ethers.service
/usr/share/doc/net-tools-2.0
/usr/share/doc/net-tools-2.0/COPYING
/usr/share/locale/cs/LC_MESSAGES/net-tools.mo
/usr/share/locale/de/LC_MESSAGES/net-tools.mo
/usr/share/locale/et_EE/LC_MESSAGES/net-tools.mo
/usr/share/locale/fr/LC_MESSAGES/net-tools.mo
/usr/share/locale/pt_BR/LC_MESSAGES/net-tools.mo
/usr/share/man/de/man5/ethers.5.gz
/usr/share/man/de/man8/arp.8.gz
/usr/share/man/de/man8/ifconfig.8.gz
/usr/share/man/de/man8/netstat.8.gz
/usr/share/man/de/man8/plipconfig.8.gz
/usr/share/man/de/man8/route.8.gz
/usr/share/man/de/man8/slattach.8.gz
/usr/share/man/fr/man5/ethers.5.gz
/usr/share/man/fr/man8/arp.8.gz
/usr/share/man/fr/man8/ifconfig.8.gz
/usr/share/man/fr/man8/netstat.8.gz
/usr/share/man/fr/man8/plipconfig.8.gz
/usr/share/man/fr/man8/route.8.gz
/usr/share/man/fr/man8/slattach.8.gz
/usr/share/man/man5/ethers.5.gz
/usr/share/man/man8/arp.8.gz
/usr/share/man/man8/ether-wake.8.gz
/usr/share/man/man8/ifconfig.8.gz
/usr/share/man/man8/ipmaddr.8.gz
/usr/share/man/man8/iptunnel.8.gz
/usr/share/man/man8/mii-diag.8.gz
/usr/share/man/man8/mii-tool.8.gz
/usr/share/man/man8/nameif.8.gz
/usr/share/man/man8/netstat.8.gz
/usr/share/man/man8/plipconfig.8.gz
/usr/share/man/man8/route.8.gz
/usr/share/man/man8/slattach.8.gz
/usr/share/man/pt/man8/arp.8.gz
/usr/share/man/pt/man8/ifconfig.8.gz
/usr/share/man/pt/man8/netstat.8.gz
/usr/share/man/pt/man8/route.8.gz
rpm 软件包通常采用默认路径安装,各安装文件会分门别类安装在适当的目录文件下。使用 rmp -ql 软件包名
可以查询到已安装软件包中包含的所有文件及各自安装路径。我们可以只过滤 bin 文件
# rpm -ql net-tools | grep bin
/bin/netstat
/sbin/arp
/sbin/ether-wake
/sbin/ifconfig
/sbin/ipmaddr
/sbin/iptunnel
/sbin/mii-diag
/sbin/mii-tool
/sbin/nameif
/sbin/plipconfig
/sbin/route
/sbin/slattach
二、查看软件包的详细信息
# rpm -qi net-tools
Name : net-tools
Version : 2.0
Release : 0.25.20131004git.el7
Architecture: x86_64
Install Date: Thu 03 Sep 2020 11:49:41 AM CST
Group : System Environment/Base
Size : 938978
License : GPLv2+
Signature : RSA/SHA256, Fri 23 Aug 2019 05:36:04 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : net-tools-2.0-0.25.20131004git.el7.src.rpm
Build Date : Fri 09 Aug 2019 09:10:26 AM CST
Build Host : x86-02.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://sourceforge.net/projects/net-tools/
Summary : Basic networking tools
Description :
The net-tools package contains basic networking tools,
including ifconfig, netstat, route, and others.
Most of them are obsolete. For replacement check iproute package.
三、查询软件包的依赖关系
# rpm -qR net-tools
/bin/sh
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libselinux.so.1()(64bit)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)
systemd-units
rpmlib(PayloadIsXz) <= 5.2-1
DPKG
dpkg 也类似
一、查询软件包文件列表
$ dpkg -L net-tools | grep bin
/bin
/bin/netstat
/sbin
/sbin/ifconfig
/sbin/ipmaddr
/sbin/iptunnel
/sbin/mii-tool
/sbin/nameif
/sbin/plipconfig
/sbin/rarp
/sbin/route
/sbin/slattach
/usr/sbin
/usr/sbin/arp
二、查看软件包(已安装)的详细信息
$ dpkg -s net-tools
Package: net-tools
Status: install ok installed
Priority: important
Section: net
Installed-Size: 844
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Multi-Arch: foreign
Version: 1.60+git20180626.aebd88e-1ubuntu1
Depends: libc6 (>= 2.14), libselinux1 (>= 1.32)
Description: NET-3 networking toolkit
This package includes the important tools for controlling the network
subsystem of the Linux kernel. This includes arp, ifconfig, netstat,
rarp, nameif and route. Additionally, this package contains utilities
relating to particular network hardware types (plipconfig, slattach,
mii-tool) and advanced aspects of IP configuration (iptunnel, ipmaddr).
.
In the upstream package 'hostname' and friends are included. Those are
not installed by this package, since there is a special "hostname*.deb".
Homepage: http://sourceforge.net/projects/net-tools/
Original-Maintainer: net-tools Team <team+net-tools@tracker.debian.org>
以上是关于RPM 与 DPKG 使用的主要内容,如果未能解决你的问题,请参考以下文章