良许Linux教程网 干货合集 ifconfig无输出的解决方法

ifconfig无输出的解决方法

本篇文章重点为大家讲解一下ifconfig无输出的解决方法,有需要的小伙伴可以参考一下。

u=1211990489,550346686&fm=26&gp=0

问题

执行 ifconfig 命令无任何报错,也无任何输出信息

[root@linuxprobe ~]#  ifconfig
[root@linuxprobe ~]#

排错

1. 检查PATH变量

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

若路径 /sbin 不在PATH变量中,执行以下命令将其加入。

export PATH=$PATH:/sbin

注:此例中 PATH 变量正常

2. 检查 /sbin/ifconfig

通常情况下,ifconfig 如果有显示,但没有某一项的信息(比如识别不到网卡)时,可以先检查 /etc/sysconfig/network-scripts/ 下配置文件是否正确。 但此例中由于执行 ifconfig 及 /sbin/ifconfig 没有任何的输出,因此先检查了下 /sbin/ifconfig 文件。发现有以下错误:

[root@linuxprobe ~]# ls -la /sbin/ifconfig
-rwxr-xr-x 1 root root 0 Apr  5 14:56 /sbin/ifconfig
[root@linuxprobe ~]# file /sbin/ifconfig
/sbin/ifconfig: empty

3. 解决方法

从局域网另一台机器上使用 scp 命令 copy 了一份 /sbin/ifconfig 到这台机器上

[root@yezi ~]#  scp /sbin/ifconfig root@192.168.10.10:/sbin
The authenticity of host '192.168.10.10 (192.168.10.10)' can't be established.
ECDSA key fingerprint is b2:e4:20:20:ae:ae:2e:20:ce:49:76:05:bd:c4:42:39.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.10' (ECDSA) to the list of known hosts.
root@192.168.10.10's password:
ifconfig                                      100%   80KB  80.1KB/s   00:00  

再执行 ifconfig , 可以正常显示了

[root@linuxprobe ~]# file /sbin/ifconfig
/sbin/ifconfig: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x64131021c4fd2c38cf37a9ed9a20bdc52e9bdf33, stripped
[root@linuxprobe ~]#  ls -al /sbin/ifconfig
-rwxr-xr-x. 1 root root 81976 Feb 14  2014 /sbin/ifconfig
[root@linuxprobe ~]# ifconfig
eno16777736: flags=4163  mtu 1500
       inet 192.168.10.10  netmask 255.255.255.0  broadcast 192.168.10.255
       inet6 fe80::20c:29ff:fe97:5c27  prefixlen 64  scopeid 0x20
       ether 00:0c:29:97:5c:27  txqueuelen 1000  (Ethernet)
       RX packets 153  bytes 16477 (16.0 KiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 166  bytes 144357 (140.9 KiB)
       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 0  (Local Loopback)
       RX packets 1431  bytes 114546 (111.8 KiB)
       RX errors 0  dropped 0  overruns 0  frame 0
       TX packets 1431  bytes 114546 (111.8 KiB)
       TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

以上就是良许教程网为各位朋友分享的Linu系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你 !

137e00002230ad9f26e78-265x300
本文由 良许Linux教程网 发布,可自由转载、引用,但需署名作者且注明文章出处。如转载至微信公众号,请在文末添加作者公众号二维码。
良许

作者: 良许

良许,世界500强企业Linux开发工程师,公众号【良许Linux】的作者,全网拥有超30W粉丝。个人标签:创业者,CSDN学院讲师,副业达人,流量玩家,摄影爱好者。
上一篇
下一篇

发表评论

联系我们

联系我们

公众号:良许Linux

在线咨询: QQ交谈

邮箱: yychuyu@163.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部