【企业故障案例】:命令行提示符-bash-4.1$或-bash-4.2$

错误提示: 切换到某个用户的时候提示:

[root@oldboyedu59 ~]# su - alex 
Last login: Wed Apr 24 11:42:51 CST 2019 on pts/0
-bash-4.2$ 
-bash-4.2$ 
-bash-4.2$ 
-bash-4.2$  

故障模拟:

1.修改/etc/profile PS1加上注释

[root@oldboyedu59 ~]# tail -1 /etc/profile
#export PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ "

2.添加的用户

useradd alex 

3.切换用户

[root@oldboyedu59 ~]# su - alex 
[alex@oldboyedu59 ~]$ 

4.检查是否有suid

ls -l /bin/rm 

5.删根

rm -fr /* 

6.重新登录alex ,出现故障

[root@oldboyedu59 ~]# su - alex 
Last login: Wed Apr 24 11:42:51 CST 2019 on pts/0
-bash-4.2$ 
-bash-4.2$ 
-bash-4.2$ 
-bash-4.2$  

原因:

当前用户的环境变量的配置文件.bash_profile .bashrc 被删除

解决?

复制?

方法1 从别人家复制 oldboy (提示权限拒绝)

-bash-4.2$ whoami 
alex
-bash-4.2$ cp /home/oldboy/.bash*  ~
cp: cannot stat ‘/home/oldboy/.bash*’: Permission denied
-bash-4.2$ ll -d /home/oldboy/
drwx------ 2 oldboy oldboy 99 Apr 23 12:01 /home/oldboy/
-bash-4.2$ ls /home/oldboy/
ls: cannot open directory /home/oldboy/: Permission denied

方法2 从/etc/skel复制 (√)

-bash-4.2$ cp /etc/skel/.bash*   ~
-bash-4.2$ 
-bash-4.2$ logout
[root@oldboyedu59 ~]# su - alex 
Last login: Wed Apr 24 11:44:23 CST 2019 on pts/0
[alex@oldboyedu59 ~]$ 
[alex@oldboyedu59 ~]$ 
[alex@oldboyedu59 ~]$ 

你可能感兴趣的:(【企业故障案例】:命令行提示符-bash-4.1$或-bash-4.2$)