解決CentOS中ifconfig命令不顯示IP地址
CentOS中ifconfig命令不顯示IP地址
[plain]view plaincopy
- $ifconfig
- bash:ifconfig:commandnotfound
環境:
非root使用者登入
[plain]view plaincopy
- $lsb_release-a
- LSBVersion::core-3.0-amd64:core-3.0-ia32:core-3.0-noarch:graphics-3.0-amd64:graphics-3.0-ia32:graphics-3.0-noarch
- DistributorID:CentOS
- Description:CentOSrelease4.3(Final)
- Release:4.3
- Codename:Final
解決:
[plain]view plaincopy
- $whereisifconfig
- ifconfig:/sbin/ifconfig.old/sbin/ifconfig/usr/share/man/man8/ifconfig.8.gz/usr/share/man/man8/ifconfig.8
[plain]view plaincopy
- $/sbin/ifconfig
- eth1Linkencap:EthernetHWaddrXXXXXXX
- inetaddr:XXXXXXXXXBcast:XXXXXXXXMask:255.255.255.128
- UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
- RXpackets:740194638errors:0dropped:398overruns:0frame:15
- TXpackets:1409116497errors:0dropped:0overruns:0carrier:0
- collisions:0txqueuelen:1000
- RXbytes:622505947542(579.7GiB)TXbytes:1299620061208(1.1TiB)
- Interrupt:36
- loLinkencap:LocalLoopback
- inetaddr:127.0.0.1Mask:255.0.0.0
- UPLOOPBACKRUNNINGMTU:16436Metric:1
- RXpackets:590278628errors:0dropped:0overruns:0frame:0
- TXpackets:590278628errors:0dropped:0overruns:0carrier:0
- collisions:0txqueuelen:0
- RXbytes:121711705636(113.3GiB)TXbytes:121711705636(113.3GiB)
解決二:
查看登入使用者的path:
[plain]view plaincopy
- $echo$PATH
path中沒有/sbin/ifconfig ,添加到path中:[plain]view plaincopy
- $exportPATH=$PATH:/sbin
再次執行:[plain]view plaincopy
- $ifconfig
- eth1Linkencap:EthernetHWaddrXXXXXXXXX
- inetaddr:XXXXXXXXBcast:XXXXXXXMask:255.255.255.128
- UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
- RXpackets:740213476errors:0dropped:398overruns:0frame:15
- TXpackets:1409138987errors:0dropped:0overruns:0carrier:0
- collisions:0txqueuelen:1000
- RXbytes:622508623742(579.7GiB)TXbytes:1299632841268(1.1TiB)
- Interrupt:36
- loLinkencap:LocalLoopback
- inetaddr:127.0.0.1Mask:255.0.0.0
- UPLOOPBACKRUNNINGMTU:16436Metric:1
- RXpackets:590326935errors:0dropped:0overruns:0frame:0
- TXpackets:590326935errors:0dropped:0overruns:0carrier:0
- collisions:0txqueuelen:0
- RXbytes:121723122294(113.3GiB)TXbytes:121723122294(113.3GiB)