linux 常用命令rpm

时间:2022-12-10 08:28:06

1、查询包信息
rpm -q <关键字> 可以查询到rpm包的名字

2、卸载包
rpm -e <包的名字> 删除特定rpm包

3、如果存在依赖,无法删除
rpm -e –nodeps <包的名字> 不检查依赖,直接删除rpm包

4、如果恰好有多个包叫同样的名字,使用–allmatches参数忽略依赖
rpm -e –allmatches –nodeps <包的名字> 删除所有相同名字的包,并忽略依赖

注意:
在安装emqtt的时候提示chkconfig包已经包含在emqtt的rpm中了,必须要先卸载才能安装emqtt。
但在安装完成以后发现/etc/init.d/目录下面的所有启动项都被清空了。
还好从另外一台机器上将init.d目录下的文件都cp过来,能正常管理相关的系统服务。

提示:file /etc/init.d from install of emqttd conflicts with file from package chkconfig

emqtt包: emqttd-centos6.8-v2.3-beta.4-1.el6.x86_64.rpm
chkconfig包: chkconfig-1.3.49.3-2.el6_4.1.x86_64

操作如下:

[root@js1t2uda4pou565zbb65jg mqtt]# rpm -q chkconfig
chkconfig-1.3.49.3-2.el6_4.1.x86_64
[root@jstu565zbb65jg mqtt]# rpm -e chkconfig-1.3.49.3-2.el6_4.1.x86_64
error: Failed dependencies:
chkconfig >= 1.3.26 is needed by (installed) dbus-glib-0.86-6.el6.x86_64
chkconfig is needed by (installed) iptables-1.4.7-11.el6.x86_64
chkconfig is needed by (installed) hal-0.5.14-11.el6.x86_64
chkconfig is needed by (installed) iptables-ipv6-1.4.7-11.el6.x86_64
chkconfig is needed by (installed) lvm2-2.02.100-8.el6.x86_64
chkconfig is needed by (installed) rng-tools-2-13.el6_2.x86_64
chkconfig is needed by (installed) smartmontools-1:5.43-1.el6.x86_64
chkconfig = 1.3.49.3-2.el6_4.1 is needed by (installed) ntsysv-1.3.49.3-2.el6_4.1.x86_64
chkconfig is needed by (installed) irqbalance-2:1.0.4-9.el6_5.x86_64
chkconfig is needed by (installed) quota-1:3.17-21.el6_5.x86_64
chkconfig is needed by (installed) audit-2.2-4.el6_5.x86_64
chkconfig >= 1.3.26 is needed by (installed) dbus-1:1.2.24-8.el6_6.x86_64
/sbin/chkconfig is needed by (installed) policycoreutils-2.0.83-19.39.el6.x86_64
/sbin/chkconfig is needed by (installed) iputils-20071127-17.el6_4.2.x86_64
/sbin/chkconfig is needed by (installed) rsyslog-5.8.10-8.el6.x86_64
/sbin/chkconfig is needed by (installed) ntpdate-4.2.6p5-1.el6.centos.x86_64
/sbin/chkconfig is needed by (installed) ntp-4.2.6p5-1.el6.centos.x86_64
/sbin/chkconfig is needed by (installed) acpid-1.0.10-2.1.el6.x86_64
/sbin/chkconfig is needed by (installed) readahead-1:1.5.6-2.el6.x86_64
/sbin/chkconfig is needed by (installed) cpuspeed-1:1.5-20.el6_4.x86_64
/sbin/chkconfig is needed by (installed) psacct-6.3.2-63.el6_3.3.x86_64
/sbin/chkconfig is needed by (installed) initscripts-9.03.40-2.el6.centos.3.x86_64
/sbin/chkconfig is needed by (installed) mdadm-3.2.6-7.el6_5.2.x86_64
/sbin/chkconfig is needed by (installed) exim-4.72-7.el6.x86_64
/sbin/chkconfig is needed by (installed) cronie-1.4.4-12.el6.x86_64
/sbin/chkconfig is needed by (installed) subversion-1.6.11-15.el6_7.x86_64
/sbin/chkconfig is needed by (installed) vsftpd-2.2.2-21.el6.x86_64
/usr/sbin/alternatives is needed by (installed) iptables-1.4.7-11.el6.x86_64
/usr/sbin/alternatives is needed by (installed) exim-4.72-7.el6.x86_64
/usr/sbin/alternatives is needed by (installed) emacs-common-1:23.1-28.el6.x86_64
/usr/sbin/alternatives is needed by (installed) mailx-12.4-8.el6_6.x86_64
/usr/sbin/alternatives is needed by (installed) imsettings-0.108.0-3.6.el6.x86_64
/usr/sbin/alternatives is needed by (installed) ibus-1.3.4-9.el6.x86_64
/usr/sbin/update-alternatives is needed by (installed) nss-3.16.1-4.el6_5.x86_64
/usr/sbin/update-alternatives is needed by (installed) p11-kit-trust-0.18.5-2.el6_5.2.x86_64


[root@js1t2uda4pou565zbb65jg mqtt]#
[root@js1t2uda4pou565zbb65jg mqtt]# /sbin/chkconfig is needed by (installed) psacct-6.3.2-63.el6_3.3.x86_64
-bash: syntax error near unexpected token `('
[root@js1t2uda4pou565zbb65jg mqtt]# rpm -e --nodeps chkconfig-1.3.49.3-2.el6_4.1.x86_64
[root@js1t2uda4pou565zbb65jg mqtt]# rpm -ihv emqttd-centos6.8-v2.3-beta.4-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:emqttd ########################################### [100%]
/var/tmp/rpm-tmp.l0aAOt: line 3: sbin/chkconfig: No such file or directory
warning: %post(emqttd-2.3-1.el6.x86_64) scriptlet failed, exit status 127