操作系统:CentOS 7
1、查看某个可执行文件所在的包
###在线查询
yum whatprovides xxxx
yum provides xxxx
比如查询cmake命令来自于哪个包,yum whatprovides cmake
[root@tencent ~]# yum whatprovides cmake
Repository epel is listed more than once in the configuration
cmake-3.11.4-3.el8.x86_64 : Cross-platform make system
仓库 :@System
匹配来源:
提供 : cmake = 3.11.4-3.el8
cmake-3.11.4-3.el8.x86_64 : Cross-platform make system
仓库 :AppStream
匹配来源:
提供 : cmake = 3.11.4-3.el8
2、搜索已经安装的包
rpm -qa 或者 yum list installed
该命令会列出所有已经安装的包,可以用grep命令过滤自己想要的包
rpm -qa|grep xxx
rpm -qa|grep -v xxx
3、查看某个包包含的文件
rpm -ql xxxx
比如查看包lsof 包含的文件
rpm -ql lsof
[root@tencent ~]# rpm -ql lsof
/usr/bin/lsof
/usr/lib/.build-id
/usr/lib/.build-id/b9
/usr/lib/.build-id/b9/f500044d50e99203ed6726f559af1b33893dd8
/usr/share/doc/lsof
/usr/share/doc/lsof/00CREDITS
/usr/share/doc/lsof/00FAQ
/usr/share/doc/lsof/00LSOF-L
/usr/share/doc/lsof/00QUICKSTART
/usr/share/doc/lsof/00README
/usr/share/man/man1/lsof.1.gz
4、查看某个文件所在的包
rpm -qf xxxx
比如查看/etc/passwd 文件所在的包
rpm -qf /etc/passwd
[root@tencent ~]# rpm -qf /etc/passwd
setup-2.12.2-2.el8_1.1.noarch
5、查看可安装的包
yum list all
可用grep 命令过滤
6、查看包的配置文件
rpm -qc xxxx
[root@tencent ~]# rpm -qc nginx
/etc/logrotate.d/nginx
/etc/nginx/fastcgi.conf
/etc/nginx/fastcgi.conf.default
/etc/nginx/fastcgi_params
/etc/nginx/fastcgi_params.default
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/mime.types
/etc/nginx/mime.types.default
/etc/nginx/nginx.conf
/etc/nginx/nginx.conf.default
/etc/nginx/scgi_params
/etc/nginx/scgi_params.default
/etc/nginx/uwsgi_params
/etc/nginx/uwsgi_params.default
/etc/nginx/win-utf
7、包完整性校验
rpm -V xxxx
比如查看包nginx 是否完整
rpm -V nginx
[root@tencent ~]# rpm -V nginx
S.5....T. c /etc/nginx/nginx.conf
如果没有列出文件表示都是正常的,如果有发生更改 或者遗漏 或者删除 的会在下面列出来
详细解释:
S=大小改变
M=权限改变
5=MD5改变
L=连接改变
D=设备改变
U=用户改变
G=组改变
T=日期和时间改变
missing=文件丢失
一般只有配置文件 发生改变才是正常的,如果是可执行文件 发生了变化就要考虑是由于升级 或者是被入侵 等原因造成的了。