0%

Linux: some very useful commands of rpm

RPM (Red Hat Package Manager) is an default open source and most popular package management utility in Redhat Linux. The tool allows users to install, update, uninstall, query, verify and manage system software packages in Unix/Linux operating systems.
Here are some very useful commands

You want to know whether httpd installed

1
2
3
[root@www 7]# rpm -qa |grep httpd
httpd-tools-2.4.6-88.el7.centos.x86_64
httpd-2.4.6-88.el7.centos.x86_64

Query all the config files of http

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@www 7]# rpm -qc httpd
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d/00-base.conf
/etc/httpd/conf.modules.d/00-dav.conf
/etc/httpd/conf.modules.d/00-lua.conf
/etc/httpd/conf.modules.d/00-mpm.conf
/etc/httpd/conf.modules.d/00-proxy.conf
/etc/httpd/conf.modules.d/00-systemd.conf
/etc/httpd/conf.modules.d/01-cgi.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd

Query all the files about httpd

1
rpm -ql httpd

If you don’t know which software a file belongs to, you can do :

1
2
3
[root@www 7]# rpm -qf /etc/rpc
glibc-2.17-260.el7_6.3.x86_64
glibc-2.17-260.el7_6.3.i686

Show all changes have been made after you install a package.

1
2
3
4
5
6
[root@www 7]# rpm -Va
..5...... /usr/lib/firmware/vpu_d.bin
S.5....T. c /etc/yum/pluginconf.d/langpacks.conf
S.5....T. c /etc/ssh/sshd_config
S.5....T. c /etc/sysctl.conf
.M....... g /var/log/dmesg

S T c g have different meanings

S :(file Size differs)
M :(Mode differs)
5 :(MD5 sum differs)
D :(Device major/minor number mis-match)
L :(readLink(2) path mis-match)
U :(User ownership differs)
G :(Group ownership differs)
T :(mTime differs)
c :(config file)
d :(documentation)
g :(ghost file)
l :(license file)
r :(read me)
###To be specific, you want to know whether special file was changed

1
2
[root@www 7]# rpm -Vf /etc/default/grub 
S.5....T. c /etc/grub.d/40_custom

It shows /etc/default/grub has been changed S(size) 5 (MD5 sum differs), T (Mtime ).