切换或者用户登录时 出现 显示 -bash-4.2$ 问题 的解决

集群的普通用户在登录用户或者切换用户时,出现 -bash-4.2$ 的状态:

[goldwind@TR-OS-DB 9.4]#su postgres
bash-4.2$

原因:在linux下通过useradd方式创建新用户时,/etc/skel下的配置文件都会复制到/home目录的新用户目录下。

解决:首先新建/home/hx目录

[goldwind@TR-OS-DB 9.4]#mkdir postgres  
[goldwind@TR-OS-DB 9.4]#ls  

但这个目录是新建的,缺少用户环境配置文件,那么复制/etc/skel这个目录的文件到/home/postgres中 (也可能有上面的文件,只是缺少配置文件)

[goldwind@TR-OS-DB 9.4]$ cp /etc/skel/.bash_logout  /home/hx/    
[goldwind@TR-OS-DB 9.4]$ cp /etc/skel/.bash_profile /home/hx  
[goldwind@TR-OS-DB 9.4]$ cp /etc/skel/.bashrc  /home/hx   

此时再切换或者登录用户即可:

原文地址:https://www.cnblogs.com/ylq1990/p/10275958.html