雖然說如今rhel已經到7版本,5版本也已淘汰,但不能否認仍有至關一部分的系統仍使用5版本在堅挺的提供服務,因此有必要搞清楚一下一些基礎知識。
bash
一、首先看問題ide
在rhel5下直接執行ifconfig命令會提示命令沒法找到,如:
oop
[reed@localhost ~]$ ifconfig -bash: ifconfig: command not found
而這樣執行則能夠,如:學習
[reed@localhost ~]$ /sbin/ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:F1:35:E1 inet addr:192.168.209.133 Bcast:192.168.209.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8413 errors:0 dropped:0 overruns:0 frame:0 TX packets:7240 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:5215094 (4.9 MiB) TX bytes:1271295 (1.2 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1635 errors:0 dropped:0 overruns:0 frame:0 TX packets:1635 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:4508168 (4.2 MiB) TX bytes:4508168 (4.2 MiB)
在rhel6版本下卻沒有這樣的問題,以下:設計
[reed@reed ~]$ ifconfig eth1 Link encap:Ethernet HWaddr 00:0C:29:A7:4F:64 inet addr:192.168.209.142 Bcast:192.168.209.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fea7:4f64/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1608 errors:0 dropped:0 overruns:0 frame:0 TX packets:869 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:584674 (570.9 KiB) TX bytes:124717 (121.7 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) virbr0 Link encap:Ethernet HWaddr 52:54:00:62:53:D7 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:11 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:2595 (2.5 KiB)
二、緣由:區別在於,rhel5下的普通用戶PATH變量不包括/sbin,而rhel6則包括,二者異同以下:ci
rhel5qt
[reed@localhost ~]$ echo $PATH /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/reed/bin
rhel6it
[reed@reed ~]$ echo $PATH /usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/reed/bin
三、解決辦法io
1)直接輸入絕對路徑命令便可,如/sbin/ifconfigast
2)修改環境變量:
2.1)臨時生效
[reed@localhost ~]$ PATH=$PATH:/sbin [reed@localhost ~]$ ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:F1:35:E1 inet addr:192.168.209.133 Bcast:192.168.209.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8935 errors:0 dropped:0 overruns:0 frame:0 TX packets:7552 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:5258006 (5.0 MiB) TX bytes:1319923 (1.2 MiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1635 errors:0 dropped:0 overruns:0 frame:0 TX packets:1635 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:4508168 (4.2 MiB) TX bytes:4508168 (4.2 MiB)
2.2)永久生效,修改.bash_profile
[reed@localhost ~]$ cat .bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin:/sbin export PATH
以上僅僅是舉例ifconfig命令,固然在5版本下的設計確實是這樣,你們能夠觸類旁通,多學習一下5和6的版本。