day7.5
day7.5
yum管理工具
yum概述
# 什么是yum?
yum也是一种rpm管理工具,相比于rpm命令,优势是可以自动解决依赖关系。
自动解决依赖关系前提条件,你的yum源中要有这些包。
# 什么是yum源
yum源:可以理解为手机中的应用商店
yum源其他名称:镜像站、yum仓库、rpm仓库
配置yum源
# 使用阿里云的yum源
http://mirrors.ali
# 系统中需要的yum源
base源:和镜像中的linux基础rpm包差不多
epel源:一些扩展安装包
# yum源的配置文件存放目录
[root@28technicians ~]# ll /etc/yum.repos.d/
total 8
-rw-r--r--. 1 root root 2523 Apr 21 11:00 CentOS-Base.repo
-rw-r--r--. 1 root root 664 Apr 21 11:02 epel.repo
# 1.删除所有官方yum源
[root@28technicians ~]# rm -f /etc/yum.re
# 2.安全方式,不使用yum源
[root@28technicians ~]# gzip -r /etc/yum.r
[root@28technicians ~]# 3.下载base源
wget-O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
curl-o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.
[root@28technicians ~]# ll /etc/yum.repos.d
-rw-r--r--1 root root 2523 Apr 2023:42 CentOS-Base.
# 4.下载epel源
wget-O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
curl-o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@28technicians ~]# ll /etc/yum.repos.d/
-rw-r--r--1 root root 2523 Apr 2023:42 CentOS-Base.repo
-rw-r--r--1 root root 664 Apr 2023:48 epel.repo
'注意:在/etc/yum/repos.d/目录下所有的yum源配置,必须以.repo结尾'
yum命令实践
yum查询
# 查看yum仓库中的所有可以安装的rpm包
[root@28technicians ~]# yum list
# 过滤看看yum仓库是否有wget包
[root@28technicians ~]# yum list|grep wget
wget.x86_64 1.14-18.el7_6.1 base 包名 版本和发布次数 在哪个仓库中
# 查看指定包详细信息
yum info 包名
# 根据命令查找包名
[root@28technicians ~]# yum provides ifconfig
# 该命令隶属于的包名
epel/x86_64/filelists_db | 12 MB 00:00:07
net-tools-2.0-0.25.20131004git.el7.x86_64 : Basic networking tools
# 该命令隶属于的仓库
Repo : @base
Matched from:
# 命令装完后,会在哪个位置下
Filename : /usr/sbin/ifconfig
# 根据命令查找属于哪个安装包,最好是写绝对路径
[root@28technicians ~]# yum provides */ifconfig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
net-tools-2.0-0.25.20131004git.el7.x86_64 : Basic networking tools
Repo : base
Matched from:
Filename : /sbin/ifconfig
net-tools-2.0-0.25.20131004git.el7.x86_64 : Basic networking tools
Repo : @base
Matched from:
Filename : /sbin/ifconfig
yum安装
# yum安装方式:
1.本地安装
yum localinstall -y 包名 (前提是已经下载在服务器上了)
2.yum源安装
yum install -y 包名
3.网站上安装
yum install -y 网站链接
'自动解决依赖的关系的前提的条件:在你所有yum源中都要有该软件的依赖包'
yum重装
# 命令
yum reinstall -y 包名
# 作用:误删除了该服务相关的任何一个文件,使用reinstall都可以恢复,但恢复的是最初的配置
reinstall的方式:必须跟着最开始安装这个包的方式一致。
yum更新
# 命令
yum check-update
# 查看当前系统中,有哪些软件是可以更新的
[root@28technicians ~]# yum check-update
# 更新指定的软件包
[root@28technicians ~]# yum check-update -y 包名
# 更新所有可更新的软件包
[root@28technicians ~]# yum update -y
yum卸载
# 命令
[root@28technicians ~]# yum erase -y 包名
[root@28technicians ~]# yum remove -y 包名
yum仓库指令
# 查看所有源中可用的yum仓库
[root@28technicians ~]# yum repolist
仓库名 仓库描述 仓库状态:多少个
repo id repo name status
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
# 查看所有源中,所有的yum仓库
[root@28technicians ~]# yum repolist all
# 使用yum-config-manager
[root@28technicians ~]# yum install -y yum-config-manager
No package yum-config-manager available.
Error: Nothing to do
(没有这个包)
# 查询该命令属于哪个包?
[root@28technicians ~]# yum provides */yum-config-manager
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
'yum-utils'1.1.31-54.el7_8.noarch : Utilities based around the yum package manager
Repo : base
Matched from:
Filename : /usr/bin/yum-config-manager
# 安装对应的rpm包
[root@28technicians ~]# yum install -y yum-utils
# 修改yum源配置文件,开启或关闭仓库
1.开启
[root@28technicians ~]# yum-config-manager --enable nginx-mainline
2.关闭
[root@28technicians ~]# yum-config-manager --disable nginx-mainline
yum缓存命令
# 清除所有缓存
yum clean all
# 加载缓存
yum makecache
'默认情况下,yum是不会下载rpm的,只会安装,除非开启下载的配置'
# 只会清除默认路径下的rpm包
yum clean packages
# 修改配置
[root@28technicians ~]# vim /etc/yum.conf
1 [main]
2 cachedir=/var/cache/yum/$basearch/$releasever
3 keepcache=0 '把0改成1就是开启下载'
4 debuglevel=2
# 仅下载,不安装
--downloadonly
# 指定下载目录
--downloaddir
# 下载nginx,不安装,并指定目录
[root@28technicians ~]# yum install nginx -y --downloadonluy --downloaddir=/opt
yum包组管理命令
# 查看有哪些包组可以安装
[root@28technicians vsftpb]# yum group list
# 安装包组
yum group install 包组名字
# 卸载包组
yum groups remove 包组名字
yum历史命令
# 查看yum历史操作
[root@28technicians vsftpb]ftpd]# yum history
命令的ID 执行的命令 执行的时间 动作 操作几个包
ID | Command line | Date and time | Action(s) | Altered
# 查看某个历史操作详细信息
[root@28technicians vsftpb]ftpd]# yum history info (ID)
# 撤销历史操作
[root@28technicians vsftpb]ftpd]# yum history undo (ID)
yum仓库配置文件
# 查询配置文件
[root@28technicians vsftpd]# vim /etc/yum.repos.d/CentOS-Base.repo
# 仓库名字
[base]
# 仓库的描述
name=CentOS-$releasever- Base - mirrors.aliyun.com
# 仓库的地址baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
# 仓库签名检查机制
gpgcheck=1
# 仓库开启/关闭(1:开启,0:关闭,默认1)
enabled=1
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了