Linux软件管理

Linux软件管理

1 yum仓库文件配置

(1)挂载本地镜像

[root@ll ~]# mount /dev/sr0 /mnt		//挂载本地镜像
mount: /mnt: /dev/sr0 已挂载于 /run/media/ll/RHEL-9-3-0-BaseOS-x86_64.
[root@ll ~]# df -h		//查看挂载镜像
文件系统               容量  已用  可用 已用% 挂载点
devtmpfs               4.0M     0  4.0M    0% /dev
tmpfs                  866M     0  866M    0% /dev/shm
tmpfs                  347M  7.2M  340M    3% /run
/dev/mapper/rhel-root   17G  4.3G   13G   27% /
/dev/nvme0n1p2         960M  292M  669M   31% /boot
/dev/nvme0n1p1         599M  7.0M  592M    2% /boot/efi
tmpfs                  174M   96K  174M    1% /run/user/1000
/dev/sr0               9.9G  9.9G     0  100% /mnt
tmpfs                  174M   36K  174M    1% /run/user/0
[root@ll ~]# 

(2)编写仓库文件

[root@ll ~]# cd /etc/yum.repos.d/
[root@ll yum.repos.d]# vim local.repo		编辑local.repo文件
[AppStream]		//名称,用于区分不同的yum仓库文件
name =AppStream		//对仓库源文件的描述
baseurl=file:// /mnt/AppStream		//yum仓库源文件目录,可选值:http://、ftp://、file://
enabled=1		//0表示仓库禁用,1表示仓库启用
gpgcheck=0		//0表示不检查,1表示检查                                              

[BaseOs]
name =BaseOs      
baseurl=file:// /mnt/AppStream    
enabled=1   
gpgcheck=0

(3)验证仓库文件

[root@ll yum.repos.d]# dnf clean all		//清除缓存
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

14 个文件已删除
[root@ll yum.repos.d]# dnf repolist all		//列出以启用的仓库
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

仓库 id                                   仓库名称                                  状态
AppStream                                 AppStream                                 启用
BaseOs                                    BaseOs                                    启用
[root@ll yum.repos.d]# dnf makecache		//构建仓库元数据
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

AppStream                                                78 MB/s | 6.5 MB     00:00    
BaseOs                                                  122 MB/s | 6.5 MB     00:00    
上次元数据过期检查:0:00:02 前,执行于 2024年08月06日 星期二 16时29分33秒。
元数据缓存已建立。
[root@ll yum.repos.d]# 

2 yum/dnf工具使用

(1)搜索、查询软件

[root@ll ~]# yum search vim		//搜索指定字符匹配的rpm包
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

上次元数据过期检查:0:05:18 前,执行于 2024年08月06日 星期二 16时29分33秒。
================================ 名称 和 概况 匹配:vim ================================
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System - GVim
vim-common.x86_64 : The common files needed by any version of the VIM editor
vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements
vim-filesystem.noarch : VIM filesystem layout
vim-minimal.x86_64 : A minimal version of the VIM editor
[root@ll ~]# yum provides ls		//列出指定的工具由哪个软件包提供
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

上次元数据过期检查:0:05:49 前,执行于 2024年08月06日 星期二 16时29分33秒。
coreutils-8.32-34.el9.x86_64 : A set of basic GNU tools commonly used in shell scripts
仓库        :@System
匹配来源:
文件名    :/usr/bin/ls

[root@ll ~]# yum list		//列出资源库和所有可以安装或更新是rpm包
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

上次元数据过期检查:0:08:30 前,执行于 2024年08月06日 星期二 16时29分33秒。
已安装的软件包
ModemManager.x86_64                            1.20.2-1.el9                   @anaconda 
......
[root@ll ~]# yum list installed		//列出所有已经安装的rpm包
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

已安装的软件包
ModemManager.x86_64                         1.20.2-1.el9                     @anaconda 
[root@ll ~]# yum list php		//列出指定的软件包
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

上次元数据过期检查:0:12:51 前,执行于 2024年08月06日 星期二 16时29分33秒。
可安装的软件包
php.x86_64                           8.0.27-1.el9_1                           AppStream
php.x86_64                           8.0.27-1.el9_1                           BaseOs   
[root@ll ~]# yum info php		//查看指定软件包的详细信息
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

上次元数据过期检查:0:13:43 前,执行于 2024年08月06日 星期二 16时29分33秒。
可安装的软件包
名称         : php
版本         : 8.0.27
发布         : 1.el9_1
架构         : x86_64
大小         : 11 k
源           : php-8.0.27-1.el9_1.src.rpm
仓库         : AppStream
概况         : PHP scripting language for creating dynamic web sites
URL          : http://www.php.net/
协议         : PHP and Zend and BSD and MIT and ASL 1.0 and NCSA
描述         : PHP is an HTML-embedded scripting language. PHP attempts to make it
             : easy for developers to write dynamically generated web pages. PHP also
             : offers built-in database integration for several commercial and
             : non-commercial database management systems, so writing a
             : database-enabled webpage with PHP is fairly simple. The most common
             : use of PHP coding is probably as a replacement for CGI scripts.

名称         : php
版本         : 8.0.27
发布         : 1.el9_1
架构         : x86_64
大小         : 11 k
源           : php-8.0.27-1.el9_1.src.rpm
仓库         : BaseOs
概况         : PHP scripting language for creating dynamic web sites
URL          : http://www.php.net/
协议         : PHP and Zend and BSD and MIT and ASL 1.0 and NCSA
描述         : PHP is an HTML-embedded scripting language. PHP attempts to make it
             : easy for developers to write dynamically generated web pages. PHP also
             : offers built-in database integration for several commercial and
             : non-commercial database management systems, so writing a
             : database-enabled webpage with PHP is fairly simple. The most common
             : use of PHP coding is probably as a replacement for CGI scripts.

[root@ll ~]# 

(2)安装、卸载软件

[root@ll yum.repos.d]# yum install php		//安装指定的软件工具
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

AppStream                                               97 MB/s | 6.5 MB     00:00    
BaseOs                                                  36 MB/s | 6.5 MB     00:00    
依赖关系解决。
=======================================================================================
 软件包                   架构         版本                      仓库             大小
=======================================================================================
安装:
 php                      x86_64       8.0.27-1.el9_1            AppStream        11 k
 ......
 [root@ll yum.repos.d]# yum remove php
正在更新 Subscription Management 软件仓库。
无法读取客户身份

本系统尚未在权利服务器中注册。可使用 subscription-manager 进行注册。

依赖关系解决。
=======================================================================================
 软件包                  架构        版本                        仓库             大小
=======================================================================================
移除:
 php                     x86_64      8.0.27-1.el9_1              @AppStream        0  
清除未被使用的依赖关系:
......

3rpm的使用

(1)安装

[root@ll Packages]# rpm -ivh  xrestop-0.4-29.el9.x86_64.rpm		//-i安装软件包、-v显示执行过程、-h列出哈希标记和-v连用
警告:xrestop-0.4-29.el9.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY
Verifying...                          ################################# [100%]
准备中...                          ################################# [100%]
正在升级/安装...
   1:xrestop-0.4-29.el9               ################################# [100%]
[root@ll Packages]# 

(2)卸载

[root@ll Packages]# rpm -ev tree-1.8.0-10.el9.x86_64		//卸载指定的安装包
软件包准备中...
tree-1.8.0-10.el9.x86_64
[root@ll Packages]# 

(3)查询

[root@ll Packages]# rpm -aq tree		//-q查询已经安装的软件包、-a查询所有安装的软件包
tree-1.8.0-10.el9.x86_64

oot@ll Packages]# rpm -ev tree-1.8.0-10.el9.x86_64 //卸载指定的安装包
软件包准备中…
tree-1.8.0-10.el9.x86_64
[root@ll Packages]#


(3)查询

```bash
[root@ll Packages]# rpm -aq tree		//-q查询已经安装的软件包、-a查询所有安装的软件包
tree-1.8.0-10.el9.x86_64
  • 16
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值