Linux 软件管理yum

Linux 软件管理yum
练习环境: VMware Workstation CentOS 7 64 位

Linux主机配置本机可访问的yum软件源

操作步骤:

1)挂载CentOS7光盘
在这里插入图片描述
2)创建仓库目录 /repo/cos7dvd

3)将光盘内的所有文档拷贝到 /repo/cos7dvd/ 目录下

4)确认仓库目录

使用本机目录作为软件源
1)清理旧配置、不可用的配置

2)添加新的软件源,指向仓库目录 file:///repo/cos7dvd

3)清理yum缓存数据

yum clean all

4)列出软件仓库列表,确认结果

扫描二维码关注公众号,回复: 9404266 查看本文章

yum repolist

yum查询软件

yum list httpd wireshark-gnome

yum安装

yum -y install httpd wireshark

yum卸载软件

yum -y remove httpd

yum 重装

yum -y reinstall vim-enhanced

//创建临时挂载点

[root@pxesvr ~]# mount -p /mnt/dvd

//挂载CentOS7光盘

[root@pxesvr ~]# mount /dev/cdrom /mnt/dvd
mount: /dev/sr0 写保护,将以只读方式挂载

//创建仓库目录/repo/cosdvd
[root@pxesvr ~]# mkdir -p /repo/cos7dvd

//将光盘内的所有文档拷贝到 /repo/cos7dvd/ 目录下

[root@pxesvr ~]# cp -rf /mnt/dvd/* /repo/cos7vd

//确认本地仓库目录

[root@pxesvr ~]# ls /repo/cos7dvd
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL

//清理旧配置、不可用的配置

//添加新的软件源,指向前一步准备的本地软件仓库

[root@pxesvr ~]# mkdir /etc/yum.repos.d/oldrepo
[root@pxesvr ~]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/oldrepo/

[root@pxesvr ~]# yum-config-manager --add-repo file:///repo/cos7dvd/
已加载插件:fastestmirror, langpacks
adding repo from: file:///repo/cos7dvd/

[repo_cos7dvd_]
name=added from: file:///repo/cos7dvd/
baseurl=file:///repo/cos7dvd/
enabled=1

//确认自动添加的配置文件

[root@pxesvr ~]# ls /etc/yum.repos.d/
oldrepo repo_cos7dvd_.repo

//取消软件签名检查

[root@pxesvr ~]# vim /etc/yum.conf

gpgcheck=0

//清理yum缓存数据

[root@pxesvr ~]# yum clean all

//列出软件仓库列表,确认结果
[root@pxesvr ~]# yum repolist
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
repo_cos7dvd_ | 3.6 kB 00:00:00
(1/2): repo_cos7dvd_/group_gz | 166 kB 00:00:00
(2/2): repo_cos7dvd_/primary_db | 3.1 MB 00:00:00
源标识 源名称 状态
repo_cos7dvd_ added from: file:///repo/cos7dvd/ 3,971
repolist: 3,971

//列出所有已安装的软件

[root@pxesvr ~]# yum list installed

//列出所有未安装但软件源能提供的软件包

[root@pxesvr ~]# yum list available

//检查软件 httpd、firefox、rar 是否已经安装

[root@pxesvr ~]# yum list httpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
可安装的软件包
httpd.x86_64 2.4.6-80.el7.centos repo_cos7dvd_

[root@pxesvr ~]# yum list firefox
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
已安装的软件包
firefox.x86_64 52.7.0-1.el7.centos @anaconda

[root@pxesvr ~]# yum list rar
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
错误:没有匹配的软件包可以列出

//查询软件包描述信息

软件包kernel主要提供Linux的运行内核程序:
[root@pxesvr ~]# yum info kernel
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
已安装的软件包
名称 :kernel
架构 :x86_64
版本 :3.10.0
发布 :862.el7
大小 :62 M
源 :installed
来自源:anaconda
简介 : The Linux kernel
网址 :http://www.kernel.org/
协议 : GPLv2
描述 : The kernel package contains the Linux kernel (vmlinuz), the core of any
: Linux operating system. The kernel handles the basic functions
: of the operating system: memory allocation, process allocation, device
: input and output, etc.

软件包bash主要为Linux系统提供命令行解释器程序(/bin/bash):

[root@pxesvr ~]# yum info bash
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
已安装的软件包
名称 :bash
架构 :x86_64
版本 :4.2.46
发布 :30.el7
大小 :3.5 M
源 :installed
来自源:anaconda
简介 : The GNU Bourne Again shell
网址 :http://www.gnu.org/software/bash
协议 : GPLv3+
描述 : The GNU Bourne Again shell (Bash) is a shell or command language
: interpreter that is compatible with the Bourne shell (sh). Bash
: incorporates useful features from the Korn shell (ksh) and the C shell
: (csh). Most sh scripts can be run by bash without modification.

软件包wireshark是非常著名的一款以太网分析工具(抓包):

[root@pxesvr ~]# yum info wireshark
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
可安装的软件包
名称 :wireshark
架构 :x86_64
版本 :1.10.14
发布 :14.el7
大小 :13 M
源 :repo_cos7dvd_
简介 : Network traffic analyzer
网址 :http://www.wireshark.org/
协议 : GPL+
描述 : Wireshark is a network traffic analyzer for Unix-ish operating systems.
:
: This package lays base for libpcap, a packet capture and filtering
: library, contains command-line utilities, contains plugins and
: documentation for wireshark. A graphical user interface is packaged
: separately to GTK+ package.

//查询哪些软件包能提供指定的程序/文件

[root@pxesvr ~]# yum provides “*bin/vim”
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo_cos7dvd_/filelists_db | 3.1 MB 00:00:00
2:vim-enhanced-7.4.160-4.el7.x86_64 : A version of the VIM editor which includes recent
: enhancements
源 :repo_cos7dvd_
匹配来源:
文件名 :/usr/bin/vim

2:vim-enhanced-7.4.160-4.el7.x86_64 : A version of the VIM editor which includes recent
enhancements
源 :@anaconda
匹配来源:
文件名 :/usr/bin/vim

//查询文件 /etc/redhat-release 由哪个软件包提供

[root@pxesvr ~]# yum provides /etc/redhat-release
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
centos-release-7-5.1804.el7.centos.x86_64 : CentOS Linux release file
源 :repo_cos7dvd_
匹配来源:
文件名 :/etc/redhat-release

centos-release-7-5.1804.el7.centos.x86_64 : CentOS Linux release file
源 :@anaconda
匹配来源:
文件名 :/etc/redhat-release

//安装 httpd、wireshark-gnome 软件包

[root@pxesvr ~]# yum list httpd wireshark
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
已安装的软件包
wireshark.x86_64 1.10.14-14.el7 @repo_cos7dvd_
可安装的软件包
httpd.x86_64 2.4.6-80.el7.centos repo_cos7dvd_
[root@pxesvr ~]# yum -y install httpd wireshark
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
软件包 wireshark-1.10.14-14.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
–> 正在检查事务
—> 软件包 httpd.x86_64.0.2.4.6-80.el7.centos 将被 安装
–> 正在处理依赖关系 httpd-tools = 2.4.6-80.el7.centos,它被软件包 httpd-2.4.6-80.el7.centos.x86_64 需要
–> 正在处理依赖关系 /etc/mime.types,它被软件包 httpd-2.4.6-80.el7.centos.x86_64 需要
–> 正在处理依赖关系 libaprutil-1.so.0()(64bit),它被软件包 httpd-2.4.6-80.el7.centos.x86_64 需要
–> 正在处理依赖关系 libapr-1.so.0()(64bit),它被软件包 httpd-2.4.6-80.el7.centos.x86_64 需要
–> 正在检查事务
—> 软件包 apr.x86_64.0.1.4.8-3.el7_4.1 将被 安装
—> 软件包 apr-util.x86_64.0.1.5.2-6.el7 将被 安装
—> 软件包 httpd-tools.x86_64.0.2.4.6-80.el7.centos 将被 安装
—> 软件包 mailcap.noarch.0.2.1.41-2.el7 将被 安装
–> 解决依赖关系完成

依赖关系解决

=======================================================================================
Package 架构 版本 源 大小

正在安装:
httpd x86_64 2.4.6-80.el7.centos repo_cos7dvd_ 2.7 M
为依赖而安装:
apr x86_64 1.4.8-3.el7_4.1 repo_cos7dvd_ 103 k
apr-util x86_64 1.5.2-6.el7 repo_cos7dvd_ 92 k
httpd-tools x86_64 2.4.6-80.el7.centos repo_cos7dvd_ 89 k
mailcap noarch 2.1.41-2.el7 repo_cos7dvd_ 31 k

事务概要

安装 1 软件包 (+4 依赖软件包)

总下载量:3.0 M
安装大小:10 M
Downloading packages:

总计 18 MB/s | 3.0 MB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : apr-1.4.8-3.el7_4.1.x86_64 1/5
正在安装 : apr-util-1.5.2-6.el7.x86_64 2/5
正在安装 : httpd-tools-2.4.6-80.el7.centos.x86_64 3/5
正在安装 : mailcap-2.1.41-2.el7.noarch 4/5
正在安装 : httpd-2.4.6-80.el7.centos.x86_64 5/5
验证中 : httpd-tools-2.4.6-80.el7.centos.x86_64 1/5
验证中 : apr-1.4.8-3.el7_4.1.x86_64 2/5
验证中 : mailcap-2.1.41-2.el7.noarch 3/5
验证中 : httpd-2.4.6-80.el7.centos.x86_64 4/5
验证中 : apr-util-1.5.2-6.el7.x86_64 5/5

已安装:
httpd.x86_64 0:2.4.6-80.el7.centos

作为依赖被安装:
apr.x86_64 0:1.4.8-3.el7_4.1 apr-util.x86_64 0:1.5.2-6.el7
httpd-tools.x86_64 0:2.4.6-80.el7.centos mailcap.noarch 0:2.1.41-2.el7

完毕!

//检查安装结果

[root@pxesvr ~]# yum list httpd wireshark
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
已安装的软件包
httpd.x86_64 2.4.6-80.el7.centos @repo_cos7dvd_
wireshark.x86_64 1.10.14-14.el7 @repo_cos7dvd_

//卸载httpd软件包

[root@pxesvr ~]# yum -y remove httpd
已加载插件:fastestmirror, langpacks
正在解决依赖关系
–> 正在检查事务
—> 软件包 httpd.x86_64.0.2.4.6-80.el7.centos 将被 删除
–> 解决依赖关系完成

依赖关系解决

=======================================================================================
Package 架构 版本 源 大小

正在删除:
httpd x86_64 2.4.6-80.el7.centos @repo_cos7dvd_ 9.4 M

事务概要

移除 1 软件包

安装大小:9.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除 : httpd-2.4.6-80.el7.centos.x86_64 1/1
验证中 : httpd-2.4.6-80.el7.centos.x86_64 1/1

删除:
httpd.x86_64 0:2.4.6-80.el7.centos

完毕!

//检查

[root@pxesvr ~]# yum list httpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
可安装的软件包
httpd.x86_64 2.4.6-80.el7.centos repo_cos7dvd_

//通过重装软件修复误删的命令程序

[root@pxesvr ~]# rm -rf /usr/bin/vim
[root@pxesvr ~]# vim /root/a.txt
bash: vim: 未找到命令…

[root@pxesvr ~]# yum -y reinstall vim-enhanced.x86_64
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
–> 正在检查事务
—> 软件包 vim-enhanced.x86_64.2.7.4.160-4.el7 将被 已重新安装
–> 解决依赖关系完成

依赖关系解决

=======================================================================================
Package 架构 版本 源 大小

重新安装:
vim-enhanced x86_64 2:7.4.160-4.el7 repo_cos7dvd_ 1.0 M

事务概要

重新安装 1 软件包

总下载量:1.0 M
安装大小:2.2 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : 2:vim-enhanced-7.4.160-4.el7.x86_64 1/1
验证中 : 2:vim-enhanced-7.4.160-4.el7.x86_64 1/1

已安装:
vim-enhanced.x86_64 2:7.4.160-4.el7

完毕!

发布了2 篇原创文章 · 获赞 5 · 访问量 738

猜你喜欢

转载自blog.csdn.net/weixin_43273856/article/details/104504442