在 CentOS 7 minimal 安裝條件下讶隐,可能會(huì)出現(xiàn) ifconfig
命令找不到的情況。
問(wèn)題
[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
結(jié)果顯示 net-tools
包提供了 ifconfig
命令。因此谓传,接下來(lái)安裝 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
目錄下。此時(shí)瘪菌,可以執(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
參考資料: