1. 程式人生 > >解決 CentOS7 安裝完成後ifconfig命令不能用

解決 CentOS7 安裝完成後ifconfig命令不能用

今天用VMWare安裝了CentOS7,選擇了最小安裝包模式,安裝完畢之後想檢視一下本機的ip地址,發現報錯

# ifconfig
-bash: ifconfig: command not found

谷歌了一下,整理了一下解決思路

  1.  檢視ifconfig命令是否存在

     檢視 /sbin/ifconfig是否存在

  2. 如果ifconfig命令存在,檢視環境變數設定    

#echo $PATH

       如果環境變數中沒有包含ifconfig命令的路徑

        臨時修改環境變數:在shell中輸入       

$export PATH = $PATH:/sbin

       然後再輸入ifconfig命令即可,但是這只是臨時更改了shell中的PATH,如果關閉shell,則修改消失,下次還需要重複如上操作

        永久修改PATH變數使之包含/sbin路徑:

        開啟/etc/profile檔案,在其中輸入export PATH=$PATH:/sbin,儲存並重啟即可,這樣一來,PATH路徑永久修改成功,以後任何時候只輸入ifconfig命令即可

  3. 如果ifconfig命令不存在

yum upgrade
yum install net-tools