/etc/profile文件改坏了,所有命令无法执行了怎么办?

问题描述:

在部署jdk的时候,修改/etc/profile文件,文件改得有问题,但是当时没有发现。直接就执行source /etc/profile将修改生效了,然后发现所有命令无法执行了:

[root@test101 apache-tomcat-8.0.48]# ll
-bash: ls: 未找到命令
[root@test101 apache-tomcat-8.0.48]# vim /etc/profile
-bash: vim: 未找到命令
[root@test101 apache-tomcat-8.0.48]# vi /etc/profile
-bash: vi: 未找到命令

解决办法:

执行 export PATH=/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin命令恢复文件

[root@test101 apache-tomcat-8.0.48]# export PATH=/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

然后就恢复了,命令也能正常使用了

[root@test101 apache-tomcat-8.0.48]# vim /etc/profile
[root@test101 apache-tomcat-8.0.48]# ll
总用量 100
drwxr-xr-x. 2 root root  4096 5月  21 11:18 bin
drwxr-xr-x. 2 root root   182 5月  21 11:17 conf
drwxr-xr-x. 2 root root  4096 11月 30 18:29 lib
-rw-r--r--. 1 root root 58068 11月 30 18:29 LICENSE
drwxr-xr-x. 2 root root     6 11月 30 18:27 logs
-rw-r--r--. 1 root root  1489 11月 30 18:29 NOTICE
-rw-r--r--. 1 root root  6964 11月 30 18:29 RELEASE-NOTES
-rw-r--r--. 1 root root 16719 11月 30 18:29 RUNNING.txt
drwxr-xr-x. 2 root root    30 11月 30 18:29 temp
drwxr-xr-x. 8 root root   116 5月  21 11:15 webapps
drwxr-xr-x. 2 root root     6 11月 30 18:27 work
[root@test101 apache-tomcat-8.0.48]# 

猜你喜欢

转载自blog.51cto.com/10950710/2118716