centos7中找不到ifconfig命令的解决⽅法
通过yum安装ifconfig
·
centos7中找不到ifconfig命令的解决⽅法
-
1
ifconfig命令是设置或显⽰⽹络接⼝的程序,可以显⽰出我们机器的⽹卡信息,可是有些时候最⼩化安装CentOS等Linux发⾏版的时候会默认不安装ifconfig等命令,这时候你进⼊终端,运⾏ifconfig命令就会出错。 -
2
⾸先想到是不是环境变量⾥没有ifconfig命令的路径,因为ifconfig是在/sbin路径下的,以root⽤户登录才可以运⾏,看看root⽤户的环境变量。 -
3
环境变量⾥有/sbin这个路径,也就是说如果ifconfig命令存在并且就是位于/sbin⽬录下的话肯定就是可以运⾏的,那么就看看/sbin⽬录下有没有ifconfig命令。结果表明/sbin⽬录下并没有ifconfig命令,所以:CentOS⾥边是没有安装ifconfig。 -
4
解决办法:使⽤yum安装ifconfig
通过yum search 这个命令我们发现ifconfig这个命令是在net-tools.x86_64这个包⾥,接下来只要安装这个包就⾏了。
yum search ifconfig
[root@host-19-15-62-17 ~]# yum search ifconfig
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
============================================== Matched: ifconfig ===============================================
net-tools.x86_64 : Basic networking tools
yum install net-tools.x86_64
[root@host-19-15-62-17 ~]# yum install net-tools.x86_64
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
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 Media 306 k
Transaction Summary
================================================================================================================
Install 1 Package
Total download size: 306 k
Installed size: 917 k
Is this ok [y/d/N]: y
Downloading packages:
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!
- 5
检查是否安装成功
[root@host-19-15-62-17 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1400
inet 19.15.0.17 netmask 255.255.255.0 broadcast 19.15.62.255
inet6 fe80::f816:3eff:fe9a:99ec prefixlen 64 scopeid 0x20<link>
ether fa:16:3e:9a:99:ec txqueuelen 1000 (Ethernet)
RX packets 23662897 bytes 1747768097 (1.6 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1606792 bytes 160965520 (153.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1400
inet 192.168.0.60 netmask 255.255.255.0 broadcast 192.168.190.255
inet6 fe80::f816:3eff:fe62:e04d prefixlen 64 scopeid 0x20<link>
ether fa:16:3e:62:e0:4d txqueuelen 1000 (Ethernet)
RX packets 25650202 bytes 6366995954 (5.9 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 48709941 bytes 7113139878 (6.6 GiB)
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 0 (Local Loopback)
RX packets 39 bytes 3647 (3.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 39 bytes 3647 (3.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@host-19-15-62-17 ~]#
- 6
原来Linux的ifconfig命令来源于net-tools,这个包有ifconfig,netstat,whois等命令,所以不安装这个包的话是无法运行相关命令的。
更多推荐
已为社区贡献1条内容
所有评论(0)