Solve the problem that the ifconfig command in CentOS does not display IP addresses
The ifconfig command in CentOS does not display IP addresses
[Plain] view plaincopy
- $ Ifconfig
- Bash: ifconfig: commandnotfound
Environment:
Non-root User Login
[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
Solution:
[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: 1500 Metric: 1
- RXpackets: 740194638 errors: 0 dropped: 398 overruns: 0 frame: 15
- TXpackets: 1409116497 errors: 0 dropped: 0 overruns: 0 carrier: 0
- Collisions: 0 FIG: 1000
- RXbytes: 622505947542 (579.7GiB) TXbytes: 1299620061208 (1.1TiB)
- Interrupt: 36
- LoLinkencap: LocalLoopback
- Inetaddr: 127.0.0.1Mask: 255.0.0.0
- UPLOOPBACKRUNNINGMTU: 16436 Metric: 1
- RXpackets: 590278628 errors: 0 dropped: 0 overruns: 0 frame: 0
- TXpackets: 590278628 errors: 0 dropped: 0 overruns: 0 carrier: 0
- Collisions: 0 txqueuelen: 0
- RXbytes: 121711705636 (113.3GiB) TXbytes: 121711705636 (113.3GiB)
Solution 2:
View the logon user's path:
[Plain] view plaincopy
- $ Echo $ PATH
Path does not contain/sbin/ifconfig. Add it to path: [plain] view plaincopy
- $ ExportPATH = $ PATH:/sbin
Execute again: [plain] view plaincopy
- $ Ifconfig
- Eth1Linkencap: EthernetHWaddrXXXXXXXXX
- Inetaddr: XXXXXXXXBcast: XXXXXXXMask: 255.255.255.128
- UPBROADCASTRUNNINGMULTICASTMTU: 1500 Metric: 1
- RXpackets: 740213476 errors: 0 dropped: 398 overruns: 0 frame: 15
- TXpackets: 1409138987 errors: 0 dropped: 0 overruns: 0 carrier: 0
- Collisions: 0 FIG: 1000
- RXbytes: 622508623742 (579.7GiB) TXbytes: 1299632841268 (1.1TiB)
- Interrupt: 36
- LoLinkencap: LocalLoopback
- Inetaddr: 127.0.0.1Mask: 255.0.0.0
- UPLOOPBACKRUNNINGMTU: 16436 Metric: 1
- RXpackets: 590326935 errors: 0 dropped: 0 overruns: 0 frame: 0
- TXpackets: 590326935 errors: 0 dropped: 0 overruns: 0 carrier: 0
- Collisions: 0 txqueuelen: 0
- RXbytes: 121723122294 (113.3GiB) TXbytes: 121723122294 (113.3GiB)