总结:
-ivh #安装
-Uvh #升级
-e #卸载
-q #查询指定软件包
-qa #查询所有已经安装的软件包
-qi #查询软件包本身相关信息
-ql #查询软件包列表信息
-qc #查询软件包相关文件
-qf #查询命令属于哪个软件包 必须是绝对路径 前提本地要已经存在这个软件包
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
命令 管理软件包 #挂载镜像 [root@qls ~]# ll /dev/sr0 brw-rw---- 1 root cdrom 11, 0 Jul 27 16:29 /dev/sr0 [root@qls ~]# ll /dev/cdrom lrwxrwxrwx 1 root root 3 Jul 27 16:29 /dev/cdrom -> sr0 [root@qls ~]# mount /dev/sr0 /mnt/ mount: /dev/sr0 is write-protected, mounting read-only [root@qls ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 98G 1.5G 97G 2% / devtmpfs 980M 0 980M 0% /dev tmpfs 991M 0 991M 0% /dev/shm tmpfs 991M 9.6M 981M 1% /run tmpfs 991M 0 991M 0% /sys/fs/cgroup /dev/sda1 497M 120M 378M 25% /boot tmpfs 199M 0 199M 0% /run/user/0 /dev/sr0 4.3G 4.3G 0 100% /mnt [root@qls ~]# ll /mnt/Packages/ | wc -l 4023 #安装 -i #安装 -v #显示安装的过程 -h #显示安装的进度条 -ivh [root@qls ~]# rpm -ivh /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:tree-1.6.0-10.el7 ################################# [100%] #删除 移除一个软件包 [root@qls ~]# rpm -e tree #rpm安装太需要依赖了,不会自动寻找依赖,需要手动下载依赖 不建议使用 #安装httpd 报错 [root@qls ~]# rpm -ivh /mnt/Packages/httpd-2.4.6-88.el7.centos.x86_64.rpm error: Failed dependencies: /etc/mime.types is needed by httpd-2.4.6-88.el7.centos.x86_64 httpd-tools = 2.4.6-88.el7.centos is needed by httpd-2.4.6-88.el7.centos.x86_64 libapr-1.so.0()(64bit) is needed by httpd-2.4.6-88.el7.centos.x86_64 libaprutil-1.so.0()(64bit) is needed by httpd-2.4.6-88.el7.centos.x86_64 #根据提示安装相关依赖 报错 [root@qls ~]# rpm -ivh /mnt/Packages/httpd-tools-2.4.6-88.el7.centos.x86_64.rpm error: Failed dependencies: libapr-1.so.0()(64bit) is needed by httpd-tools-2.4.6-88.el7.centos.x86_64 libaprutil-1.so.0()(64bit) is needed by httpd-tools-2.4.6-88.el7.centos.x86_64 #查找相关依赖包 [root@qls ~]# ll /mnt/Packages/ | grep apr -rw-rw-r-- 1 root root 105728 Nov 29 2017 apr-1.4.8-3.el7_4.1.x86_64.rpm -rw-rw-r-- 1 root root 192652 Nov 29 2017 apr-devel-1.4.8-3.el7_4.1.x86_64.rpm -rw-rw-r-- 1 root root 94132 Jul 4 2014 apr-util-1.5.2-6.el7.x86_64.rpm -rw-rw-r-- 1 root root 78072 Jul 4 2014 apr-util-devel-1.5.2-6.el7.x86_64.rpm -rw-rw-r-- 1 root root 854420 Nov 12 2018 haproxy-1.5.18-8.el7.x86_64.rpm #安装相关依赖 [root@qls ~]# rpm -ivh /mnt/Packages/apr-1.4.8-3.el7_4.1.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:apr-1.4.8-3.el7_4.1 ################################# [100%] [root@qls ~]# rpm -ivh /mnt/Packages/apr-util-1.5.2-6.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:apr-util-1.5.2-6.el7 ################################# [100%] #尝试安装httpd-tools [root@qls ~]# rpm -ivh /mnt/Packages/httpd-tools-2.4.6-88.el7.centos.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:httpd-tools-2.4.6-88.el7.centos ################################# [100%] #再次安装httpd 报错 [root@qls ~]# rpm -ivh /mnt/Packages/httpd-2.4.6-88.el7.centos.x86_64.rpm error: Failed dependencies: /etc/mime.types is needed by httpd-2.4.6-88.el7.centos.x86_64 #搜索相关文件的依赖包 [root@qls ~]# yum provides /etc/mime.types Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.ustc.edu.cn * epel: fedora.cs.nctu.edu.tw * extras: mirrors.aliyun.com * updates: mirrors.ustc.edu.cn mailcap-2.1.41-2.el7.noarch : Helper application and MIME type associations for file types Repo : base Matched from: Filename : /etc/mime.types #安装依赖包 [root@qls ~]# rpm -ivh /mnt/Packages/mailcap-2.1.41-2.el7.noarch.rpm Preparing... ################################# [100%] Updating / installing... 1:mailcap-2.1.41-2.el7 ################################# [100%] #最终安装成功 [root@qls ~]# rpm -ivh /mnt/Packages/httpd-2.4.6-88.el7.centos.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:httpd-2.4.6-88.el7.centos ################################# [100%] [root@qls ~]# #联网安装软件包 [root@qls ~]# rpm -ivh https://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/Packages/tree-1.6.0-10.el7.x86_64.rpm Retrieving https://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/Packages/tree-1.6.0-10.el7.x86_64.rpm Preparing... ################################# [100%] Updating / installing... 1:tree-1.6.0-10.el7 ################################# [100%] #升级安装 -U #升级 [root@qls ~]# rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.0-2.el7.x86_64.rpm Retrieving https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.0-2.el7.x86_64.rpm warning: /var/tmp/rpm-tmp.jseg5b: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY Preparing... ################################# [100%] Updating / installing... 1:zabbix-agent-4.0.0-2.el7 ################################# [100%] [root@qls ~]# zabbix_agentd -V zabbix_agentd (daemon) (Zabbix) 4.0.0 Revision 85308 1 October 2018, compilation time: Oct 1 2018 08:41:36 Copyright (C) 2018 Zabbix SIA License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it according to the license. There is NO WARRANTY, to the extent permitted by law. #升级安装 [root@qls ~]# rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/x86_64/zabbix-agent-4.4.0-1.el7.x86_64.rpm Retrieving https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/x86_64/zabbix-agent-4.4.0-1.el7.x86_64.rpm warning: /var/tmp/rpm-tmp.e9rZWk: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY Preparing... ################################# [100%] Updating / installing... 1:zabbix-agent-4.4.0-1.el7 ################################# [ 50%] Cleaning up / removing... 2:zabbix-agent-4.0.0-2.el7 ################################# [100%] [root@qls ~]# zabbix_agentd -V zabbix_agentd (daemon) (Zabbix) 4.4.0 Revision cfac660b25 7 October 2019, compilation time: Oct 7 2019 11:26:17 Copyright (C) 2019 Zabbix SIA License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it according to the license. There is NO WARRANTY, to the extent permitted by law. This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/). Compiled with OpenSSL 1.0.1e-fips 11 Feb 2013 Running with OpenSSL 1.0.1e-fips 11 Feb 2013 #查询指定的软件包是否安装 [root@qls ~]# rpm -q tree tree-1.6.0-10.el7.x86_64 [root@qls ~]# rpm -q ifconfig package ifconfig is not installed [root@qls ~]# rpm -q net-tools net-tools-2.0-0.25.20131004git.el7.x86_64 #显示所有已经安装的软件包 [root@qls ~]# rpm -qa | grep tree tree-1.6.0-10.el7.x86_64 #查询软件包列表信息 [root@qls ~]# rpm -ql httpd /etc/httpd /etc/httpd/conf /etc/httpd/conf.d /etc/httpd/conf.d/README /etc/httpd/conf.d/autoindex.conf /etc/httpd/conf.d/userdir.conf /etc/httpd/conf.d/welcome.conf #查询相关配置文件信息 [root@qls ~]# 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 #查询软件包本身信息 [root@qls ~]# rpm -qi httpd Name : httpd Version : 2.4.6 Release : 88.el7.centos Architecture: x86_64 Install Date: Thu 30 Jul 2020 09:03:08 AM CST Group : System Environment/Daemons Size : 9817309 License : ASL 2.0 Signature : RSA/SHA256, Mon 12 Nov 2018 10:28:53 PM CST, Key ID 24c6a8a7f4a80eb5 Source RPM : httpd-2.4.6-88.el7.centos.src.rpm Build Date : Mon 05 Nov 2018 09:48:57 AM CST Build Host : x86-01.bsys.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : http://httpd.apache.org/ Summary : Apache HTTP Server Description : The Apache HTTP Server is a powerful, efficient, and extensible web server. #使用绝对路径查询命令属于哪个软件包 前提系统已经安装这个软件 [root@qls ~]# rpm -qf `which ping` iputils-20160308-10.el7.x86_64 [root@qls ~]# which ping /usr/bin/ping [root@qls ~]# rpm -qf /usr/bin/ping iputils-20160308-10.el7.x86_64 |