在CentOS安装以后,执行ifconfig发现命令找不到,需要安装

[root@localhost ~]# ifconfig
-bash: ifconfig: command not found

首先设置yum源,设置为阿里的镜像,这样速度会快很多

  1. 备份,防止更改失败
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. 从阿里的镜像,下载新的CentOS-Base.repo
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 
-bash: wget: command not found

发现wget并没有安装,需要先安装wget,成功

[root@localhost yum.repos.d]# yum install wget

安装结束后再次重试下载新的CentOS-Base.repo

[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 
--2020-07-15 09:21:01--  http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 124.193.244.231, 124.200.113.115, 124.200.113.111, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|124.193.244.231|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’

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

2020-07-15 09:21:01 (337 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]
  1. 使用yum安装ifconfig
    首先对ifconfig进行查找
[root@localhost yum.repos.d]# yum search ifconfig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
============================================================================================================= Matched: ifconfig ==============================================================================================================
net-tools.x86_64 : Basic networking tools

发现它在net-tools.x86_64这个包里面,直接使用yum安装,安装后再试试ifconfig已经能够运行。

[root@localhost ~]# ifconfig -a
enp0s3: flags=4163  mtu 1500
        inet 10.0.2.4  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::2d47:804c:6877:7ceb  prefixlen 64  scopeid 0x20
        ether 08:00:27:0f:83:3f  txqueuelen 1000  (Ethernet)
        RX packets 8195  bytes 11784042 (11.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4074  bytes 257812 (251.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163  mtu 1500
        inet 192.168.31.95  netmask 255.255.255.0  broadcast 192.168.31.255
        inet6 fe80::e4f5:6544:8b5c:9ea6  prefixlen 64  scopeid 0x20
        ether 08:00:27:3d:0e:64  txqueuelen 1000  (Ethernet)
        RX packets 39293  bytes 4918546 (4.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1323  bytes 213003 (208.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 16  bytes 1408 (1.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16  bytes 1408 (1.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

文章来源于互联网,如有雷同请联系站长删除:在CentOS 7中安装软件

发表评论