1. 程式人生 > >linux下執行常用命令出現:command not found

linux下執行常用命令出現:command not found

linux 下執行類似與 ls、ll、vim 等命令時出現 command not found,並且執行 source /etc/profile 出現

bash: id: command not found
bash: tty: command not found

可能是因為 /etc/profile 下配置環境變數時出現了問題,例如:

export JAVA_HOME=/usr/local/share/java/jdk1.8.0_151
export PATH=$PTAH:$JAVA_HOME/bin

可以看到我把 $PATH 寫成了 $PTAH ,導致了我的環境變數失效。

解決方案:使用下面的命令修改 /etc/profile

檔案,然後斷開 linux 連線,重新連線即可。

/bin/vi /etc/profile