CentOS7 没有安装 ifconfig 命令

      ifconfig 命令是设置或显示网络接口的程序,可以显示出我们机器的网卡信息。

      除此之外, ip a 命令,也可以设置或显示网卡的信息

      在 CentOS 7 下,默认 ifconfig 命令是没有安装的。进入终端,运行 ifconfig 命令会报错:

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

      当然,若是对 Centos 7 操作系统不熟悉的话,根据正常思维来处理此问题,如下:

首先会想到是不是环境变量里没有ifconfig命令的路径,因为ifconfig是在/sbin路径下的,

以root用户登录才可以运行,可是我们上边是以root用户登录的啊,不急,我们来看看root用户的环境变量

[root@test ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

从以上操作中可以看到,环境变量里有/sbin这个路径,也就是说如果ifconfig命令存在并且就是位于/sbin目录下的话我们肯定就是可以运行的,那么我们就看看/sbin目录下有没有ifconfig命令吧。

[root@test ~]# ls /sbin |grep ifconfig
[root@test ~]# 

结果表明我们的/sbin目录下并没有ifconfig命令,所以我们的结论是:我们的CentOS里边是没有安装ifconf。

解决办法

      ifconfig 命令是在 net-tools.x86_64 这个包里,接下来,我们只需要安装这个包就行了。

      命令如下:

[root@test ~]# yum -y install net-tools


[root@test ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.194  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::3b8:ad34:e049:cb7d  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:f5:bc:27  txqueuelen 1000  (Ethernet)
        RX packets 1779759  bytes 560107686 (534.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 94438  bytes 14358022 (13.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 399  bytes 34684 (33.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 399  bytes 34684 (33.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
扫描二维码关注公众号,回复: 7778503 查看本文章

猜你喜欢

转载自www.cnblogs.com/morgan363/p/11814244.html