软件管理(redhat 8.0)

本文介绍了在Red Hat 8.0中如何进行软件管理,包括RPM包的分类、命名规范、安装、查询、升级和卸载。此外,还讲解了YUM本地和网页源仓库的搭建,以及YUM常用命令的使用,如安装、更新、卸载软件包和查询软件信息。
摘要由CSDN通过智能技术生成

软件管理

软件包分类

  • 二进制格式(编译好的,装上就可以用)
    • rpm包作者下载源程序,编译配置完成后,制作成rpm包
    • why would we do that? because:
      • 有些特性是编译时选定的,如果编译时未选定此特性,将无法使用
      • rpm包的版本会落后于源码包,甚至落后很多
  • 源码格式(需要编译,也叫定制)
    • 命名方式:name-VERSION.tar.gz
      • VERSION:major.minor.release

rpm包名规范

bash-4.2.46-28.el7.x86_64.rpm

  • bash:软件名称

  • 4.2.46:版本号

  • 28.el7:发布次数

  • x86_64:硬件平台(_64表示适用于64位系统)

  • 包的组成

    • 主包:bind-9.7.1-1.el5.i586.rpm
    • bind-libs-9.7.1-1.el5.i586.rpm bind-utils-9.7.1-1.el5.i586.rpm
  • 包的格式

    • name-version-release-arch.cpm
      - bind-major.minor.release-release.arch.rpm
  • 包名格式说明

    • major(主版本号):重大改进
    • minor(次版本号):某个子功能发生重大变化
    • release(发行号):修正了部分bug,调整了一点功能
  • 常见的arch

    • x86:i386,i486,i586,i686
    • x86_64:x64,x86_64,amd64
    • 跟平台无关:noarch

RPM包安装

语法:rpm -ivh /path
常用选项:
-i: 安装
-v: 显示详细信息
-h: 显示安装进度条
–test: 测试安装,但不真正执行安装过程
–nodeps: 忽略依赖关系
–replacepkgs: 重新安装,替换原有安装
–oldpackage: 降级
–force: 强行安装,可以实现重装或降级
–nodigest: 不检查包的完整性
–nosignature: 不检查包的来源合法性
–noscripts: 不执行程序包脚本片断
%pre:安装前脚本 --nopre
%post:安装后脚本 --nopost
%preun:卸载前脚本 --nopreun
%postun:卸载后脚本 --nopostun

rpm -ivh

[root@yukino ~]# rpm -ivh /mnt/BaseOS/Packages/hostname-3.20-6.el8.x86_64.rpm 
警告:/mnt/BaseOS/Packages/hostname-3.20-6.el8.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
	软件包 hostname-3.20-6.el8.x86_64 已经安装

rpm -ivh --test /path
测试软件包是否可以安装

[root@yukino ~]# rpm -ivh --test /mnt/BaseOS/Packages/hardlink-1.3-6.el8.x86_64.rpm 
警告:/mnt/BaseOS/Packages/hardlink-1.3-6.el8.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%

rpm -ivh /path --replacepkgs
重新安装软件包,覆盖原有的软件包

[root@yukino ~]# rpm -ivh /mnt/BaseOS/Packages/hardlink-1.3-6.el8.x86_64.rpm --replacepkgs 
警告:/mnt/BaseOS/Packages/hardlink-1.3-6.el8.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:hardlink-1:1.3-6.el8             ################################# [100%]

rpm -e PackageName
卸载安装包

[root@yukino ~]# rpm -qa | grep hardlink
hardlink-1.3-6.el8.x86_64
[root@yukino ~]# rpm -e hardlink 	

RPM包查询

rpm -q PACKAGE_NAME                 //查询指定的包是否已安装
rpm -qa                             //查询已经安装的所有包
rpm -qi PACKAGE_NAME                //查询指定包的说明信息
rpm -ql PACKAGE_NAME                //查询指定软件包安装后生成的文件列表
rpm -qf /path/to/somefile           //查询指定的文件是由哪个rpm包安装生成的
rpm -qc PACKAGE_NAME                //查询指定包安装的配置文件
rpm -qd PACKAGE_NAME                //查询指定包安装的帮助文件
rpm -q --scripts PACKAGE_NAME       //查询指定包中包含的脚本
rpm -q --whatprovides CAPABILITY    //查询指定的CAPABILITY(能力)由哪个包所提供
    如:rpm -q --whatprovides /bin/cat
rpm -q --whatrequires CAPABILITY    //查询指定的CAPABILITY被哪个包所依赖
rpm -q --changelog COMMAND          //查询COMMAND的制作日志
rpm -q --scripts PACKAGE_NAME       //查询指定软件包包含的所有脚本文件
rpm -qR PACKAGE_NAME                //查询指定的软件包所依赖的CAPABILITY
rpm -q --provides PACKAGE_NAME      //列出指定软件包所提供的CAPABILITY

rpm -qpi /PATH/TO/PACKAGE_FILE      //查询指定未安装包的说明信息
rpm -qpl /PATH/TO/PACKAGE_FILE      //查询未安装的软件包会产生哪些文件

rpm -q
#查询软件包是否安装

[root@yukino ~]# rpm -q nginx
nginx-1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
	 

rpm -qa
#查询所有安装的包

[root@yukino ~]# rpm -qa | tail -5
python3-magic-5.33-8.el8.noarch
npth-1.5-4.el8.x86_64
libblockdev-mdraid-2.19-11.el8.x86_64
libwebp-1.0.0-1.el8.x86_64
libXext-1.3.3-9.el8.x86_64

rpm -qi
#查询安装包的详细信息

[root@yukino ~]# rpm -qi nginx
Name        : nginx
Epoch       : 1
Version     : 1.14.1
Release     : 9.module+el8.0.0+4108+af250afe
Architecture: x86_64
Install Date: 2020年08月10日 星期一 21时21分18秒
Group       : System Environment/Daemons
Size        : 1734591
License     : BSD
Signature   : RSA/SHA256, 2019年09月02日 星期一 04时47分04秒, Key ID 199e2f91fd431d51
Source RPM  : nginx-1.14.1-9.module+el8.0.0+4108+af250afe.src.rpm
Build Date  : 2019年08月30日 星期五 06时17分42秒
Build Host  : x86-vm-08.build.eng.bos.redhat.com
Relocations : (not relocatable)
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
Vendor      : Red Hat, Inc.
URL         : http://nginx.org/
Summary     : A high performance web server and reverse proxy server
Description :
Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and
IMAP protocols, with a strong focus on high concurrency, performance and low
memory usage.

rpm -ql PACKAGE_NAME
#查询指定软件包安装后生成的文件列表

[root@yukino ~]# rpm -ql 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
/usr/bin/nginx-upgrade
/usr/lib/.build-id
/usr/lib/.build-id/af
/usr/lib/.build-id/af/024040a062afc15f1418d95b7dbb6ca7bdcc3a
/usr/lib/systemd/system/nginx.service
/usr/lib64/nginx/modules
/usr/sbin/nginx
/usr/share/doc/nginx
/usr/share/doc/nginx/CHANGES
/usr/share/doc/nginx/README
/usr/share/doc/nginx/README.dynamic
/usr/share/licenses/nginx
/usr/share/licenses/nginx/LICENSE
/usr/share/man/man3/nginx.3pm.gz
/usr/share/man/man8/nginx-upgrade.8.gz
/usr/share/man/man8/nginx.8.gz
/usr/share/nginx/html/404.html
/usr/share/nginx/html/50x.html
/usr/share/nginx/html/index.html
/usr/share/nginx/html/nginx-logo.png
/usr/share/nginx/html/poweredby.png
/usr/share/vim/vimfiles/ftdetect/nginx.vim
/usr/share/vim/vimfiles/indent/nginx.vim
/usr/share/vim/vimfiles/syntax/nginx.vim
/var/lib/nginx
/var/lib/nginx/tmp
/var/log/ngin 

rpm -qf /path
#查看指定文件是由哪个安装包生成的

[root@yukino ~]# rpm -qf /etc/nginx/nginx.conf
nginx-1.16.1-1.module+el8.1.0+4097+739b0d87.x86_64

rpm -qc package_name
#查询指定包安装的配置文件

[root@yukino ~]# 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

rpm -q --scripts package_name
#查询安装包中包含的脚本

[root@yukino ~]# rpm -q --scripts nginx
postinstall scriptlet (using /bin/sh):

if [ $1 -eq 1 ] ; then 
        # Initial installation 
        systemctl --no-reload preset nginx.service &>/dev/null || : 
fi
preuninstall scriptlet (using /bin/sh):

if [ $1 -eq 0 ] ; then 
        # Package removal, not upgrade 
        systemctl --no-reload disable --now nginx.service &>/dev/null || : 
fi
postuninstall scriptlet (using /bin/sh):

if [ $1 -ge 1 ]; then
    /usr/bin/nginx-upgrade >/dev/null 2>&1 || :
fi

RPM包升级

rpm -Uvh /PATH/TO/NEW_PACKAGE_FILE  //如果装有老版本的,则升级;否则,则安装
rpm -Fvh /PATH/TO/NEW_PACKAGE_FILE  //如果装有老版本的,则升级;否则,退出
    --oldpackage:降级
    
[root@localhost ~]# rpm -Uvh /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm

rpm -Uvh

[root@yukino ~]# rpm -Uvh /mnt/AppStream/Packages/vsftpd-3.0.3-28.el8.x86_64.rpm 
警告:/mnt/AppStream/Packages/vsftpd-3.0.3-28.el8.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:vsftpd-3.0.3-28.el8              ################################# [100%]

RPM包卸载

//语法:rpm -e PACKAGE_NAME

//先查询, 然后卸载 
[root@localhost ~]# rpm -qa |grep vsftpd
[root@localhost ~]# rpm -e vsftpd

yum与dnf
由于使用yum在安装软件包时可能会出现ctrl+c中断后无法重新安装,于是就有了dnf这个命令。
除此之外两个命令完全相同
dnf install

[root@wcluser ~]# dnf install rpcbind
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository base is listed more than once in the configuration
上次元数据过期检查:0:00:09 前,执行于 2020年08月12日 星期三 02时55分06秒。
依赖关系解决。
=============================================================================================================================================================
 软件包                               架构                                版本                                       仓库                               大小
=============================================================================================================================================================
安装:
 rpcbind                              x86_64                              1.2.5-7.el8                                base                               70 k

事务概要
=============================================================================================================================================================
安装  1 软件包

总下载:70 k
安装大小:108 k
确定吗?[y/N]: y
下载软件包:
rpcbind-1.2.5-7.el8.x86_64.rpm                                                                                               242 kB/s |  70 kB     00:00    
-------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                         241 kB/s |  70 kB     00:00     
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                                                              1/1 
  运行脚本: rpcbind-1.2.5-7.el8.x86_64                                                                                                                   1/1 
  安装    : rpcbind-1.2.5-7.el8.x86_64                                                                                                                   1/1 
  运行脚本: rpcbind-1.2.5-7.el8.x86_64                                                                                                                   1/1 
  验证    : rpcbind-1.2.5-7.el8.x86_64                                                                                                                   1/1 
Installed products updated.

已安装:
  rpcbind-1.2.5-7.el8.x86_64                                                                                                                                 

完毕!

dnf remove

[root@wcluser ~]# dnf remove rpcbind
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository base is listed more than once in the configuration
模块依赖问题

 问题 1: conflicting requests
  - nothing provides module(perl:5.26) needed by module perl-DBD-MySQL:4.046:8010020191114030811:073fa5fe-0.x86_64
 问题 2: conflicting requests
  - nothing provides module(perl:5.26) needed by module perl-DBI:1.641:8010020191113222731:16b3ab4d-0.x86_64
依赖关系解决。
=============================================================================================================================================================
 软件包                               架构                                版本                                      仓库                                大小
=============================================================================================================================================================
移除:
 rpcbind                              x86_64                              1.2.5-7.el8                               @base                              108 k

事务概要
========================================================================================
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值