ifconfig: command not found

在 CentOS 7 minimal 安装条件下,可能会出现 ifconfig 命令找不到的情况。

问题

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

解决方案

首先查看哪些包提供 ifconfig 命令:

[root@localhost ~]# yum provides */ifconfig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.neusoft.edu.cn
 * extras: mirrors.neusoft.edu.cn
 * updates: mirrors.neusoft.edu.cn
net-tools-2.0-0.25.20131004git.el7.x86_64 : Basic networking tools
Repo        : base
Matched from:
Filename    : /sbin/ifconfig

结果显示 net-tools 包提供了 ifconfig 命令。因此,接下来安装 net-tools 包:

[root@localhost ~]# yum install net-tools -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.neusoft.edu.cn
 * extras: mirrors.neusoft.edu.cn
 * updates: mirrors.neusoft.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.25.20131004git.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================================
 Package                                   Arch                                   Version                                                   Repository                            Size
=======================================================================================================================================================================================
Installing:
 net-tools                                 x86_64                                 2.0-0.25.20131004git.el7                                  base                                 306 k

Transaction Summary
=======================================================================================================================================================================================
Install  1 Package

Total download size: 306 k
Installed size: 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
  Installing : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                                                           1/1 
  Verifying  : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                                                           1/1 

Installed:
  net-tools.x86_64 0:2.0-0.25.20131004git.el7                                                                                                                                          

Complete!

包安装成功后,ifconfig 命令存在于 /sbin 目录下。此时,可以执行 ifconfig 命令:

[root@localhost ~]# ifconfig
eth0: flags=4163  mtu 1500
        inet 192.168.186.168  netmask 255.255.255.240  broadcast 192.168.186.175
        inet6 fe80::c9a9:f496:8957:688a  prefixlen 64  scopeid 0x20
        ether 00:15:5d:1c:41:02  txqueuelen 1000  (Ethernet)
        RX packets 82150  bytes 122324670 (116.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 47826  bytes 3338960 (3.1 MiB)
        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 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

参考资料:

  • How to install ifconfig on CentOS 7 Linux

你可能感兴趣的:(ifconfig: command not found)