問題描述:
用虛擬機VMware安裝linux系統(鏡像文件是從官網下載的CentOS-7.0-1406-x86_64-DVD.iso),
在安裝完成之后,輸入ifconfig命令報錯:ifconfig command not found
解決思路:
1 確定是否是沒有安裝ifconfig,如果沒有,添加上去
2 確定是否是沒有添加到環境變量上,如果沒有,添加上去
解決方法:
首先判斷一下是不是缺少了ifconfig,它是在/sbin目錄下的 [root@localhost ~]# cd /sbin [root@localhost sbin]# ls 查看一下是否有 ifconfig 沒有 ifconfig 的話安裝 net-tools package [root@localhost sbin]# sudo yum install net-tools
參考:https://blog.csdn.net/dandelion_drq/article/details/53503487
當然,如果指定目錄下已經存在ifconfig,也有可能是其它問題導致,比如環境變量沒有添加:
原本使用ifconfig 可以使用,今天是怎么了,可能安裝軟件修改了,百度~~ [oracle@localhost /]$ ifconfig 提示:“bash: ifconfig: command not found” 於是我切換到root用戶下 [root@localhost /]$ ifconfig 依然提示:“bash: ifconfig: command not found” 分析問題 1.whereis ifconfig 看一下這個命令在哪個目錄下 2.echo $PATH 看一下該目錄是否在路經下,注意lunux下是完全區分大小寫的,所以不要忽略這點 3.執行命令,需要指定路徑或者把目錄加入PATH中 4.於是可以這樣訪問 方法一:[root@localhost sbin]$ /sbin/ifconfig 就可以出現使用了 方法二:[root@localhost sbin]$ export PATH=$PATH:/sbin ,這樣設置后,下次就可以直接訪問了,免處第一種的麻煩,如: [root@localhost /]$ ifconfig 方法三:修改/etc/profile文件,注釋掉if語句即可 把下面的if語句注釋掉: # Path manipulation if [ "$EUID" = "0" ]; then pathmunge /sbin pathmunge /usr/sbin pathmunge /usr/local/sbin fi 修改為 # Path manipulation # if [ "$EUID" = "0" ]; then pathmunge /sbin pathmunge /usr/sbin pathmunge /usr/local/sbin #fi 注:不光是ifconfig命令出現“bash: ifconfig: command not found”,原因非root用戶的path中沒有/sbin/ifconfig ,其它的命令也可以出現這種情況,解決的方法是一樣的。 --------------------- 本文來自 xu1314 的CSDN 博客 ,全文地址請點擊:https://blog.csdn.net/xu1314/article/details/6951762?utm_source=copy