Mac系统修改.bash_profile文件改坏了,导致除cd以外的命令基本失效
如:
-bash: ls: command not found
-bash: shutdown: command not found
-bash: reboot: command not found
-bash: vi: command not found
此时还可以使用shell脚本的绝对路径操作
1.打开.bash_profile文件
方式一:(亲测有效)
/usr/bin/vim ~/.bash_profile
方式二:
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
open -e ~/.bash_profile
2.打开.bash_profile文件之后把之前的错误修改干掉,一般是PATH赋值有问题
保存并强制退出
:wq!
3.退出后使配置生效
source ~/.bash_profile
稍微等一会基本既可以恢复
由于添加一个工具的路径错误导致整个终端的命令无法使用:
//错误的添加路径
export PATH="/Users/username/kotlin-native-macos-x86_64-1.7.20/bin"
//正确的添加路径
export PATH=$PATH:/Users/username/kotlin-native-macos-x86_64-1.7.20/bin
// 参考文章
https://blog.csdn.net/yuanfang_jlht/article/details/53101695
https://www.cnblogs.com/jzxy/p/11535306.html
http://www.bloguan.com/?id=536