Linux PATH环境变量配置错误
程序员文章站
2022-05-10 09:09:54
...
PATH 环境变量配置错误
使用xshell连接的linux
正确的
export PATH=.:$PATH:${JAVA_HOME}/bin
错误的
export PATH=.:PATH:${JAVA_HOME}/bin
结果就是...
[[email protected] h3cu]# vi /etc/profile
[[email protected] h3cu]# source /etc/profile
[[email protected] h3cu]# env | grep HOME
-bash: grep: command not found
-bash: env: command not found
[[email protected] h3cu]# env
-bash: env: command not found
[[email protected] h3cu]# grep
-bash: grep: command not found
[[email protected] h3cu]# ll
-bash: ls: command not found
[[email protected] h3cu]# ll
-bash: ls: command not found
[[email protected] h3cu]# ls
-bash: ls: command not found
[[email protected] h3cu]# cd
[[email protected] ~]# ll
-bash: ls: command not found
[[email protected] ~]# ls
-bash: ls: command not found
[[email protected] ~]# su hadoop
-bash: su: command not found
[[email protected] ~]# vi /etc/profile
-bash: vi: command not found
[[email protected] ~]# cat /profile
-bash: cat: command not found
[[email protected] ~]# reboot
-bash: reboot: command not found
很多命令都不可用
但是cd 还是可以使用的(虽然这时候cd毫无作用)
有两种解决方法:
- 使用xftp修改/etc/profile文件
- 从其他虚拟机scp profile文件过来
目的就是恢复写错的PATH
scp <发送文件的主机的用户名>@<发送文件的主机名>:/etc/profile <接收文件的主机的用户名>@<接受文件的用户名>:/etc
尝试改了profile文件的内容之后直接在命令行里source
[[email protected] ~]# source /etc/profile
/usr/libexec/grepconf.sh: line 5: grep: command not found
输入命令还是毫无改变
发现reboot命令可以使用了
[[email protected] ~]# reboot
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(ALmaster) at 12:08:24.
Type `help' to learn how to use Xshell prompt.
[D:\~]$
重启之后就可以使用了
上一篇: linux非root用户执行开机启动程序