问题
执行 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
免费提供最新Linux技术教程书籍,为开源技术爱好者努力做得更多更好:https://www.linuxprobe.com/