linux-管理rpm包

一、概念

1、RPM:RPM是RedHat Package Manager(RedHat软件包管理工具)的缩写。
2、RPM包的名称构成:

例如:ypserv-2.31-12.el7.x86_64.rpm,yelp-xsl-3.28.0-1.el7.noarch.rpm

软件包名 版本号 发布版本 系统平台
ypserv 2.31 12.el7 x86_64
yelp-xsl 3.28.0 1.el7 noarch

二、yum管理rpm包

1、yum源:
(1)、默认源:BASE/Extras/Updates默认都是国外源,可以替换为国内镜像源,比如阿里和网易的镜像源(https://developer.aliyun.com/mirror ,http://mirrors.163.com)
(2)、EPEL 源:EPEL (Extra Packages for Enterprise Linux)是基于Fedora的一个项目,为“红帽系”的操作系统提供额外的软件包,适用于RHEL、CentOS等。默认是国外源;可以替换为国内阿里云镜像。
(3)、第三方软件源:比如mysql,zabbix等等都有自己的官方源
(4)、yum源配置文件

存放位置:/etc/yum.repos.d/*.repo
源配置文件中的主要参数:
[base] ##标签名称
name=CentOS-$releasever - Base ##名称
baseurl=http://mirror.centos.org/centos/ r e l e a s e v e r / o s / releasever/os/ releasever/os/basearch/ ##r指向yum存储库的“repodata”目录所在目录的URL,可以是http://, ftp:// or file://
gpgcheck=1 ## 是否签名检查 1: 检查 0:不检查
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 ## 签名检查密钥文件

2、yum命令:

使用yum安装软件包时可以自动寻找依赖包并安装。

(1)、查看可用仓库:
##清空缓存文件
[root@centos7u7 yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base extras updates
Cleaning up list of fastest mirrors

##重建缓存
[root@centos7u7 yum.repos.d]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
base                                                   | 3.6 kB  00:00:00     
extras                                                 | 2.9 kB  00:00:00     
updates                                                | 2.9 kB  00:00:00     
(1/10): base/7/x86_64/group_gz                         | 165 kB  00:00:00     
(2/10): extras/7/x86_64/filelists_db                   | 207 kB  00:00:01     
(3/10): extras/7/x86_64/primary_db                     | 153 kB  00:00:01     
(4/10): extras/7/x86_64/other_db                       | 100 kB  00:00:01     
(5/10): base/7/x86_64/other_db                         | 2.6 MB  00:00:13     
(6/10): updates/7/x86_64/filelists_db                  | 2.1 MB  00:00:13     
(7/10): updates/7/x86_64/other_db                      | 243 kB  00:00:01     
(8/10): updates/7/x86_64/primary_db                    | 2.8 MB  00:00:15     
(9/10): base/7/x86_64/filelists_db                     | 7.3 MB  00:00:21     
(10/10): base/7/x86_64/primary_db                      | 6.0 MB  00:00:21     
元数据缓存已建立

##查询可用仓库
[root@centos7u7 yum.repos.d]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
源标识                        源名称                        状态
base/7/x86_64                 CentOS-7 - Base               10,097
extras/7/x86_64               CentOS-7 - Extras                305
updates/7/x86_64              CentOS-7 - Updates               711
repolist: 11,113

(2)、查询命令:

查询命令是从本地rpm数据库和yum源中查询

命令 功能
yum list bash-completion 查找某个包,全匹配
yum list bash-com* 查找某个包,模糊匹配,只在名称查找匹配
yum list|grep ^bash-com 查找某个包,模糊匹配,只在名称查找匹配
yum search chinese 在名称和描述中查找关键字,上面的命令只在名称中查找
yum list installed 列出已安装的包
yum info bash-completion.noarch 显示包的详细信息
yum provides /etc/yum.conf 查找文件由哪个包提供
yum provides watch 查找命令由哪个包提供
##查询某一rpm包,可以全匹配或模糊匹配,结果中的@代表已安装
[root@centos7u7 yum.repos.d]# yum list bash-completion
[root@centos7u7 yum.repos.d]# yum list bash-com*
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
已安装的软件包
bash-completion.noarch             1:2.1-6.el7            @base
[root@centos7u7 yum.repos.d]# yum list|grep ^bash-com
bash-completion.noarch                      1:2.1-6.el7                @base

##列出安装软件包
[root@centos7u7 yum.repos.d]# yum list installed

##列出软件包详细信息
[root@centos7u7 yum.repos.d]# yum info bash-completion.noarch 
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
已安装的软件包
名称    :bash-completion
架构    :noarch
时期       :1
版本    :2.1
发布    :6.el7
大小    :259 k
源    :installed
来自源:base
简介    : Programmable completion for Bash
网址    :http://bash-completion.alioth.debian.org/
协议    : GPLv2+
描述    : bash-completion is a collection of shell functions that take advantage
         : of the programmable completion feature of bash.


[root@centos7u7 yum.repos.d]# yum search chinese
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
======================================================= N/S matched: chinese ========================================================
ghostscript-chinese.noarch : Common files for ghostscript-chinese
ghostscript-chinese-zh_CN.noarch : Ghostscript Simplified Chinese fonts configuration files
ghostscript-chinese-zh_TW.noarch : Ghostscript Traditional Chinese fonts configuration files
google-noto-sans-simplified-chinese-fonts.noarch : Sans Simplified Chinese font
google-noto-sans-traditional-chinese-fonts.noarch : Sans Traditional Chinese font
ibus-table-chinese.noarch : Chinese input tables for IBus
kde-l10n-Chinese.noarch : Chinese (Simplified Chinese) language support for KDE
kde-l10n-Chinese-Traditional.noarch : Chinese (Traditional) language support for KDE
autocorr-zh.noarch : Chinese auto-correction rules
cjkuni-ukai-fonts.noarch : Chinese Unicode TrueType font in Kai face

##查找文件由哪个包提供
[root@centos7u7 yum.repos.d]# yum provides /etc/yum.conf
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
yum-3.4.3-163.el7.centos.noarch : RPM package installer/updater/manager
源    :base
匹配来源:
文件名    :/etc/yum.conf

yum-3.4.3-163.el7.centos.noarch : RPM package installer/updater/manager
源    :@anaconda
匹配来源:
文件名    :/etc/yum.conf

##查找命令由哪个包提供
[root@centos7u7 yum.repos.d]# yum provides watch
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
procps-ng-3.3.10-26.el7.i686 : System and process monitoring utilities
源    :base
匹配来源:
文件名    :/usr/bin/watch



procps-ng-3.3.10-26.el7.x86_64 : System and process monitoring utilities
源    :base
匹配来源:
文件名    :/usr/bin/watch



procps-ng-3.3.10-26.el7_7.1.i686 : System and process monitoring utilities
源    :updates
匹配来源:
文件名    :/usr/bin/watch

(3)、安装命令
命令 功能
yum -y install vsftpd *vnc 安装vsftpd,*vnc软件包
yum -y reinstall httpd 重装httpd软件包
yum -y updatevsftpd 更新vsftpd软件包
yum -y update 更新所有已安装软件包
yum -y install /media/Packages/yp-tools-2.9-12.el6.x86_64.rpm 从本地安装软件包
yum install https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.28-1.el7.x86_64.rpm 从网络安装软件包
[root@centos6 ~]# yum -y reinstall vsftpd
已加载插件:fastestmirror, refresh-packagekit, security
设置覆盖安装进程
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
解决依赖关系
--> 执行事务检查
---> Package vsftpd.x86_64 0:2.2.2-24.el6 will be reinstalled
--> 完成依赖关系计算

依赖关系解决

=====================================================================================================================================
 软件包                        架构                          版本                                  仓库                         大小
=====================================================================================================================================
Reinstalling:
 vsftpd                        x86_64                        2.2.2-24.el6                          base                        156 k

事务概要
=====================================================================================================================================
Reinstall     1 Package(s)

总下载量:156 k
Installed size: 340 k
下载软件包:
vsftpd-2.2.2-24.el6.x86_64.rpm                                                                                | 156 kB     00:00     
运行 rpm_check_debug 
执行事务测试
事务测试成功
执行事务
  正在安装   : vsftpd-2.2.2-24.el6.x86_64                                                                                        1/1 
  Verifying  : vsftpd-2.2.2-24.el6.x86_64                                                                                        1/1 

已安装:
  vsftpd.x86_64 0:2.2.2-24.el6                                                                                                       

完毕!

[root@centos6 ~]# yum update vsftpd
已加载插件:fastestmirror, refresh-packagekit, security
设置更新进程
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
不升级任何软件包

[root@centos6 ~]# yum -y install vsftpd
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
包 vsftpd-2.2.2-24.el6.x86_64 已安装并且是最新版本
无须任何处理

(4)、卸载命令:
命令 功能
yum -y remove vsftpd 卸载vsftpd软件包
yum history 查看yum历史
yum history info 4 查看yum历史4号命令信息
yum history undo 4 回退yum历史4号命令
[root@centos6 ~]# yum -y remove vsftpd
已加载插件:fastestmirror, refresh-packagekit, security
设置移除进程
解决依赖关系
--> 执行事务检查
---> Package vsftpd.x86_64 0:2.2.2-24.el6 will be 删除
--> 完成依赖关系计算

依赖关系解决

=====================================================================================================================================
 软件包                        架构                          版本                                 仓库                          大小
=====================================================================================================================================
正在删除:
 vsftpd                        x86_64                        2.2.2-24.el6                         @base                        340 k

事务概要
=====================================================================================================================================
Remove        1 Package(s)

Installed size: 340 k
下载软件包:
运行 rpm_check_debug 
执行事务测试
事务测试成功
执行事务
  正在删除   : vsftpd-2.2.2-24.el6.x86_64                                                                                        1/1 
  Verifying  : vsftpd-2.2.2-24.el6.x86_64                                                                                        1/1 

删除:
  vsftpd.x86_64 0:2.2.2-24.el6                                                                                                       

完毕!

[root@centos6 ~]# yum history
已加载插件:fastestmirror, refresh-packagekit, security
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     6 | root <root>              | 2019-11-07 20:34 | Erase          |    1   
     5 | root <root>              | 2019-11-07 20:20 | Reinstall      |    1   
     4 | root <root>              | 2019-11-07 20:20 | Install        |    1   
     3 | root <root>              | 2019-11-07 20:07 | Install        |    5   
     2 | root <root>              | 2019-08-03 11:50 | Install        |    1   
     1 | 系统 <>                | 2019-07-24 05:43 | Install        | 1007   
history list
[root@centos6 ~]# 
[root@centos6 ~]# yum history info 6
已加载插件:fastestmirror, refresh-packagekit, security
Transaction ID : 6
Begin time     : Thu Nov  7 20:34:24 2019
Begin rpmdb    : 1014:2309f4bd95bc01461eca9ccd390ef37572a2624f
End time       :                          (0 seconds)
End rpmdb      : 1013:be6d05eae33f4a0dc886026301dc38fd1041d0f0
User           : root <root>
Return-Code    : Success
Command Line   : -y remove vsftpd
Transaction performed with:
    已安装        rpm-4.8.0-55.el6.x86_64                       @anaconda-CentOS-201605220104.x86_64/6.8
    已安装        yum-3.2.29-73.el6.centos.noarch               @anaconda-CentOS-201605220104.x86_64/6.8
    已安装        yum-plugin-fastestmirror-1.1.30-37.el6.noarch @anaconda-CentOS-201605220104.x86_64/6.8
Packages Altered:
    Erase vsftpd-2.2.2-24.el6.x86_64 @base
history info
[root@centos6 ~]#
[root@centos6 ~]# yum -y history undo 6
已加载插件:fastestmirror, refresh-packagekit, security
Undoing transaction 6, from Thu Nov  7 20:34:24 2019
    Erase vsftpd-2.2.2-24.el6.x86_64 @base
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
解决依赖关系
--> 执行事务检查
---> Package vsftpd.x86_64 0:2.2.2-24.el6 will be 安装
--> 完成依赖关系计算

依赖关系解决

=====================================================================================================================================
 软件包                        架构                          版本                                  仓库                         大小
=====================================================================================================================================
正在安装:
 vsftpd                        x86_64                        2.2.2-24.el6                          base                        156 k

事务概要
=====================================================================================================================================
Install       1 Package(s)

总下载量:156 k
Installed size: 340 k
下载软件包:
vsftpd-2.2.2-24.el6.x86_64.rpm                                                                                | 156 kB     00:00     
运行 rpm_check_debug 
执行事务测试
事务测试成功
执行事务
  正在安装   : vsftpd-2.2.2-24.el6.x86_64                                                                                        1/1 
  Verifying  : vsftpd-2.2.2-24.el6.x86_64                                                                                        1/1 

已安装:
  vsftpd.x86_64 0:2.2.2-24.el6                                                                                                       

完毕!

(5)、yum签名检查机制:

rpm软件包提供组织(如redhat)在构建rpm包时,使用其私钥对rpm包进行签名,客户端在安装rpm包时,为了验证其合法性,可以使用redhat提供的公钥(public key)进行前面检查。
使用签名机制检查方法:

****方法一:实现导入公钥
[root@centos6 yum.repos.d]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[root@centos6 yum.repos.d]# 
[root@centos6 yum.repos.d]# vi CentOS-Base.repo 
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1


****方法二:指定公钥位置
[root@centos6 yum.repos.d]# vi CentOS-Base.repo 
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
(6)、添加EPEL源
##默认添加国外源
[root@centos6 yum.repos.d]# yum -y install epel-release
##添加阿里云镜像源 可以查看阿里云帮助文档,见下图
[root@centos6 yum.repos.d]# mv /etc/yum.repos.d/{epel.repo,epel.repo.bak}
[root@centos6 yum.repos.d]# mv /etc/yum.repos.d/{epel-testing.repo,epel-testing.repo.bak}
[root@centos6 yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

在这里插入图片描述
linux-管理rpm包_第1张图片

(7)、修改默认yum源为国内镜像源
***修改为阿里云镜像源
[root@centos6 yum.repos.d]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@centos6 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
--2019-11-07 21:28:45--  http://mirrors.aliyun.com/repo/Centos-6.repo
正在解析主机 mirrors.aliyun.com... 119.167.173.245, 119.167.173.238, 119.167.173.239, ...
正在连接 mirrors.aliyun.com|119.167.173.245|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

100%[===========================================================================================>] 2,523       --.-K/s   in 0s      

2019-11-07 21:28:45 (374 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])
[root@centos6 yum.repos.d]# more CentOS-Base.repo
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
[root@centos6 yum.repos.d]# yum clean all
[root@centos6 yum.repos.d]# yum makecache
[root@centos6 yum.repos.d]# yum repolist
已加载插件:fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
仓库标识     仓库名称                                          状态
base         CentOS-6 - Base - mirrors.aliyun.com               6,713
epel         Extra Packages for Enterprise Linux 6 - x86_64    12,568
extras       CentOS-6 - Extras - mirrors.aliyun.com                46
updates      CentOS-6 - Updates - mirrors.aliyun.com              708
repolist: 20,035
 


****修改163镜像源
[root@centos6 yum.repos.d]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup1
[root@centos6 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
[root@centos6 yum.repos.d]# yum clean all
[root@centos6 yum.repos.d]# yum makecache
[root@centos6 yum.repos.d]# yum repolist
已加载插件:fastestmirror, refresh-packagekit, security
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Loading mirror speeds from cached hostfile
仓库标识        仓库名称                                            状态
base            CentOS-6 - Base - 163.com                            6,713
epel            Extra Packages for Enterprise Linux 6 - x86_64      12,568
extras          CentOS-6 - Extras - 163.com                             46
updates         CentOS-6 - Updates - 163.com                           708
repolist: 20,035

3、yum配置文件:

/etc/yum.conf

[root@centos6 etc]# cat yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever   ## cache缓存文件目录
keepcache=0  ## 是否保留缓存
debuglevel=2  
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=19&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release

4、将安装光盘配置成本地yum源:
(1)、挂载光盘
[root@centos7u7 /]# mount /dev/cdrom /media
mount: /dev/sr0 写保护,将以只读方式挂载

或者:
[root@centos7u7 /]# mount -o loop centos7u7.iso /media
(2)、添加yum源
[root@centos7u7 /]# vi /etc/yum.repos.d/cdrom.repo

[cdrom]
name=cdrom
baseurl=file:///media
gpgcheck=0

(3)、查看可用仓库:
[root@centos7u7 /]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base cdrom extras updates
Cleaning up list of fastest mirrors
[root@centos7u7 /]# 
[root@centos7u7 /]# yum makecache 
[root@centos7u7 /]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.jdcloud.com
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirror.jdcloud.com
源标识                          源名称                         状态
base/7/x86_64                   CentOS-7 - Base                10,097
cdrom                           cdrom                           4,067
extras/7/x86_64                 CentOS-7 - Extras                 305
updates/7/x86_64                CentOS-7 - Updates                711
repolist: 15,180

5、将普通目录配置成本地yum源

只需要比将安装光盘配置成本地yum源多一步 创建repodata

(1)、创建目录并copy安装包:
[root@centos7u7 opt]# mkdir repo
[root@centos7u7 opt]# cp /media/Packages/x* /opt/repo/
(2)、创建repodata(注意:如果有新增加的rpm包,则需要重新创建repodata)
[root@centos7u7 opt]# createrepo /opt/repo/
Spawning worker 0 with 47 pkgs
Spawning worker 1 with 47 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@centos7u7 opt]# 
[root@centos7u7 opt]# cd /opt/repo
[root@centos7u7 repo]# ls -d 
.
[root@centos7u7 repo]# ls
repodata                                                xorg-x11-drv-qxl-0.1.5-5.el7.x86_64.rpm
x3270-3.3.12ga12-4.el7.x86_64.rpm                       xorg-x11-drv-synaptics-1.9.0-2.el7.x86_64.rpm

(3)、添加yum源
[root@centos7u7 repo]# vi /etc/yum.repos.d/local.repo

[local]
name=local
baseurl=file:///opt/repo/
gpgcheck=0

(4)、查看可用仓库:
[root@centos7u7 repo]# yum clean all
[root@centos7u7 yum.repos.d]# yum makecache
[root@centos7u7 yum.repos.d]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
源标识                 源名称                                     状态
base/7/x86_64          CentOS-7 - Base - mirrors.aliyun.com       10,097
cdrom                  cdrom                                       4,067
extras/7/x86_64        CentOS-7 - Extras - mirrors.aliyun.com        305
local                  local                                          94
updates/7/x86_64       CentOS-7 - Updates - mirrors.aliyun.com       711
repolist: 15,274

三、rpm工具管理rpm包

rpm包网址:
https://pkgs.org/
ftp://rpmfind.net

rpm管理软件包,需要手工确认:
1、操作系统版本 ## cat /etc/redhat-release
2、系统架构   ## uname -m
3、包的依赖关系
1、查询命令:
命令 功能 查询范围
rpm -q vsftpd 或 rpm -qa|grep vsftpd 查询vsftpd是否安装 本地rpm数据库
rpm -ql vsftpd 查询vsftpd安装的文件 本地rpm数据库
rpm -qf /etc/vsftpd/vsftpd.conf 查询文件属于哪个安装包 本地rpm数据库
rpm -qi vsftpd 查询vsftpd的详细信息 本地rpm数据库
rpm -qc vsftpd 查询vsftpd的配置文件 本地rpm数据库
rpm -qd vsftpd 查询vsftpd的帮助文档 本地rpm数据库
rpm -qdp vsftpd-3.0.2-25.el7.x86_64.rpm 查询vsftpd的帮助文档 -p参数 没有安装rpm包的情况下,在rpm包中查询
[root@centos7u7 Packages]# rpm -q vsftpd
vsftpd-3.0.2-25.el7.x86_64
[root@centos7u7 media]# rpm -qa|grep ftp
vsftpd-3.0.2-25.el7.x86_64
[root@centos7u7 media]# rpm -ql vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
...

[root@centos7u7 media]# rpm -qf /etc/vsftpd/vsftpd.conf
vsftpd-3.0.2-25.el7.x86_64
[root@centos7u7 media]# rpm -qf /etc/vsftpd/vsftpd.conf
vsftpd-3.0.2-25.el7.x86_64
[root@centos7u7 media]# 
[root@centos7u7 media]# rpm -qi vsftpd
Name        : vsftpd
Version     : 3.0.2
Release     : 25.el7
Architecture: x86_64
Install Date: 2019年11月08日 星期五 15时14分10秒
Group       : System Environment/Daemons
Size        : 361335
License     : GPLv2 with exceptions
Signature   : RSA/SHA256, 2018年11月12日 星期一 22时48分54秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : vsftpd-3.0.2-25.el7.src.rpm
Build Date  : 2018年10月31日 星期三 03时45分10秒
Build Host  : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : https://security.appspot.com/vsftpd.html
Summary     : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.
[root@centos7u7 media]# 
[root@centos7u7 media]# rpm -qc vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
[root@centos7u7 media]# 
[root@centos7u7 media]# rpm -qd vsftpd
/usr/share/doc/vsftpd-3.0.2/AUDIT
/usr/share/doc/vsftpd-3.0.2/BENCHMARKS
/usr/share/doc/vsftpd-3.0.2/BUGS
/usr/share/doc/vsftpd-3.0.2/COPYING
/usr/share/doc/vsftpd-3.0.2/Changelog
...
[root@centos7u7 media]# 
[root@centos7u7 media]# rpm -qip Packages/vsftpd-3.0.2-25.el7.x86_64.rpm
Name        : vsftpd
Version     : 3.0.2
Release     : 25.el7
Architecture: x86_64
Install Date: (not installed)
Group       : System Environment/Daemons
Size        : 361335
License     : GPLv2 with exceptions
Signature   : RSA/SHA256, 2018年11月12日 星期一 22时48分54秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : vsftpd-3.0.2-25.el7.src.rpm
Build Date  : 2018年10月31日 星期三 03时45分10秒
Build Host  : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : https://security.appspot.com/vsftpd.html
Summary     : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.

2、安装命令:

命令 功能
rpm -ivh zsh-5.0.2-33.el7.x86_64.rpm 从本地安装包
rpm -ivh http://mirror.centos.org/centos/7/os/x86_64/Packages/ModemManager-glib-1.6.10-3.el7_6.x86_64.rpm 从网址安装包
rpm -Uvh zsh-5.0.2-33.el7.x86_64.rpm 更新包
–nosignature 不验证包签名
–force 强制软件包
–nodepts 不检查依赖关系
[root@centos7u7 Packages]# rpm -ivh zsh-5.0.2-33.el7.x86_64.rpm 
准备中...                          ################################# [100%]
正在升级/安装...
   1:zsh-5.0.2-33.el7                 ################################# [100%]
[root@centos7u7 Packages]# 

rpm -ivh http://mirror.centos.org/centos/7/os/x86_64/Packages/ModemManager-glib-1.6.10-3.el7_6.x86_64.rpm
获取http://mirror.centos.org/centos/7/os/x86_64/Packages/ModemManager-glib-1.6.10-3.el7_6.x86_64.rpm
准备中...                          ################################# [100%]
正在升级/安装...
   1:ModemManager-glib-1.6.10-3.el7_6 ################################# [100%]
[root@centos7u7 Packages]# 

3、卸载命令:

命令 功能
rpm -e zsh 或 rpm --erase zsh 卸载软件包
[root@centos7u7 Packages]# rpm -e zsh
[root@centos7u7 Packages]# 
[root@centos7u7 Packages]# rpm -Uvh zsh-5.0.2-33.el7.x86_64.rpm --force
准备中...                          ################################# [100%]
正在升级/安装...
   1:zsh-5.0.2-33.el7                 ################################# [100%]
[root@centos7u7 Packages]# 
[root@centos7u7 Packages]# rpm --erase zsh
[root@centos7u7 Packages]# 
[root@centos7u7 Packages]# rpm --erase zsh
错误:未安装软件包 zsh 
[root@centos7u7 Packages]# 

你可能感兴趣的:(linux,linux)