ifconfig: command not found

在 CentOS 7 minimal 安裝條件下,可能會出現(xiàn) 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 目錄下。此時,可以執(zhí)行 ifconfig 命令:

[root@localhost ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  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<link>
        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<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 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

參考資料:

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容