Linux基本操作(10)-软件包的管理-RPM包,yum安装

一、RPM包管理

在这里插入图片描述

1、yum工具

1)配置yum仓库/yum源
① 设置网络为NAT模式
在这里插入图片描述
②打开LINUX网络设置
在这里插入图片描述
③ 打开浏览器测试
在这里插入图片描述
2)目的:使用国内厂商提供的软件包地址作为仓库源
3)步骤:
① 安装可以下载的工具wget,然后清理yum源
yum install wget
mv /etc/yum.repos.d/* /tmp

[root@localhost etc]# yum install wget
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ftp.sjtu.edu.cn
 * extras: ftp.sjtu.edu.cn
 * updates: ftp.sjtu.edu.cn
软件包 wget-1.14-18.el7_6.1.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost etc]# 
[root@localhost etc]# mkdir /home/yum.repos.d
[root@localhost etc]# mv /etc/yum.repos.d/* /home/yum.repos.d
[root@localhost etc]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
[root@localhost yum.repos.d]#

② 下载阿里源到yum库
wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/CentOS-Base.repo

[root@localhost yum.repos.d]# wget  http://mirrors.aliyun.com/repo/Centos-7.repo  -O /etc/yum.repos.d/CentOS-Base.repo 
--2021-03-27 15:47:46--  http://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 111.6.252.114, 111.7.104.238, 111.7.173.78, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|111.6.252.114|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

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

2021-03-27 15:47:46 (248 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])

[root@localhost yum.repos.d]#

③ 下载EPEL企业LInux的额外软件包
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
--2021-03-27 15:48:26--  http://mirrors.aliyun.com/repo/epel-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 111.6.252.118, 111.6.234.237, 111.7.104.238, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|111.6.252.118|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:664 [application/octet-stream]
正在保存至: “/etc/yum.repos.d/epel.repo”

100%[=============================================>] 664         --.-K/s 用时 0s      

2021-03-27 15:48:26 (36.0 MB/s) - 已保存 “/etc/yum.repos.d/epel.repo” [664/664])

[root@localhost yum.repos.d]# 

④ 更新yum源 ,重建缓存
yum repolist
yum makecache

[root@localhost yum.repos.d]# yum repolist
已加载插件:fastestmirror, langpacks
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,072
epel/x86_64              Extra Packages for Enterprise Linux 7 - x86_64          13,567
extras/7/x86_64          CentOS-7 - Extras - mirrors.aliyun.com                     463
updates/7/x86_64         CentOS-7 - Updates - mirrors.aliyun.com                  1,901
repolist: 26,003
[root@localhost yum.repos.d]# yum makecache
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                            | 3.6 kB  00:00:00     
epel                                                            | 4.7 kB  00:00:00     
extras                                                          | 2.9 kB  00:00:00     
updates                                                         | 2.9 kB  00:00:00     
元数据缓存已建立
[root@localhost yum.repos.d]# 

2、YUM管理包使用:

在这里插入图片描述

  1. 全新安装:[root@localhost ~]# yum -y install httpd vsftpd
  [root@localhost yum.repos.d]# yum -y install httpd 
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
软件包 httpd-2.4.6-97.el7.centos.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost yum.repos.d]# 

2)重新安装:[root@localhost ~]# yum -y reinstall httpd

3)升级安装:[root@localhost ~]# yum -y update httpd
全部升级:[root@localhost ~]# yum -y update

4)查询YUM源:[root@localhost ~]# yum repolist

[root@localhost yum.repos.d]# yum  repolist
已加载插件:fastestmirror, langpacks
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,072
epel/x86_64              Extra Packages for Enterprise Linux 7 - x86_64          13,567
extras/7/x86_64          CentOS-7 - Extras - mirrors.aliyun.com                     463
updates/7/x86_64         CentOS-7 - Updates - mirrors.aliyun.com                  1,901
repolist: 26,003
[root@localhost yum.repos.d]# 

5)查询HTTP程序:[root@localhost ~]# yum list httpd

[root@localhost yum.repos.d]# yum list httpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
已安装的软件包
httpd.x86_64                        2.4.6-97.el7.centos                        @updates
[root@localhost yum.repos.d]# 

6)卸载程序:[root@localhost ~]# yum -y remove httpd

7)如果命令失效怎么办:比如 ifconfig。
① 直接 yum -y install ifconfig
② 如果不能解决,直接查询命令出处:[root@localhost ~]# yum provides ifconfig
③ 安装对应的安装包
列如:

[root@localhost yum.repos.d]# ifconfig
bash: ifconfig: 未找到命令...
[root@localhost yum.repos.d]# yum -y install ifconfig
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
没有可用软件包 ifconfig。
错误:无须任何处理
[root@localhost yum.repos.d]# yum provides ifconfig
已加载插件:fastestmirror, langpacks
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
源    :base
匹配来源:
文件名    :/sbin/ifconfig



[root@localhost yum.repos.d]# yum -y install net-tools
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 net-tools.x86_64.0.2.0-0.25.20131004git.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=======================================================================================
 Package           架构           版本                              源            大小
=======================================================================================
正在安装:
 net-tools         x86_64         2.0-0.25.20131004git.el7          base         306 k

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

总下载量:306 k
安装大小:917 k
Downloading packages:
net-tools-2.0-0.25.20131004git.el7.x86_64.rpm                   | 306 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : net-tools-2.0-0.25.20131004git.el7.x86_64                          1/1 
  验证中      : net-tools-2.0-0.25.20131004git.el7.x86_64                          1/1 

已安装:
  net-tools.x86_64 0:2.0-0.25.20131004git.el7                                          

完毕!
[root@localhost yum.repos.d]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.128  netmask 255.255.255.0  broadcast 192.168.10.255
        ether 00:0c:29:f7:27:85  txqueuelen 1000  (Ethernet)
        RX packets 43429  bytes 59114613 (56.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 19918  bytes 1506004 (1.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost yum.repos.d]# 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值