天天看點

CentOS7_ifconfig command not found1. 問題描述2. 監測是否有ifconfig4. 參考連結

CentOS7_ifconfig command not found

  • 1. 問題描述
  • 2. 監測是否有ifconfig
    • 2.1 ifconfig指令存在
      • 2.1.1 臨時修改環境變量
      • 2.1.2. 永久修改PATH變量使之包含/sbin路徑:
    • 2.2 ifconfig指令不存在
      • 2.2.1 下載下傳ifconfig
  • 4. 參考連結

1. 問題描述

當安裝完

CentOS 7 Minimal

時,會發現

ifconfig

netstat

等網絡相關指令無法使用,報錯

ifconfig command not found

.這是因為安裝的最簡版,這些都沒有進行安裝。

2. 監測是否有ifconfig

[[email protected] ~]# cd /sbin
[[email protected] sbin]# ls
           

2.1 ifconfig指令存在

如果ifconfig指令存在,檢視環境變量設定,這個大機率原因是

ifconfig

不在環境變量中

echo $PATH
           

2.1.1 臨時修改環境變量

如果環境變量中沒有包含

ifconfig

指令的路徑,

臨時修改環境變量:在

Shell

中輸入

$export PATH = $PATH:/sbin
           

然後再輸入

ifconfig

指令即可,但是這隻是臨時更改了

shell

中的

PATH

,如果關閉

shell

,則修改消失,下次還需要重複如上操作

2.1.2. 永久修改PATH變量使之包含/sbin路徑:

打開`/etc/profile`檔案,在其中輸入`export PATH=$PATH:/sbin`,儲存并重新開機即可,這樣一來,PATH路徑永久修改成功,以後任何時候隻輸入`ifconfig`指令即可
           

2.2 ifconfig指令不存在

2.2.1 下載下傳ifconfig

如果沒有

ifconfig

,需要安裝

net-tools package

[[email protected] sbin]# sudo yum install net-tools

4. 參考連結

https://stackoverflow.com/questions/24839810/ifconfig-command-not-found

繼續閱讀