Linux 切换用户出现“-bash-4.2$”

问题原因:
用户丢失家目录下的环境变量文件:.bash_profile、.bashrc、.bash_logout

解决方式:

如切换到postgres用户:

[root@localhost ~]# su - postgres
Last login: Fri Apr 10 21:02:21 CST 2020 on pts/4
-bash-4.2$

则copy相关文件到postgres用户家目录下:

[root@localhost ~]# cp /etc/skel/.bash_logout /home/postgres/
[root@localhost ~]# cp /etc/skel/.bash_profile /home/postgres/
[root@localhost ~]# cp /etc/skel/.bashrc /home/postgres/

重新切换至用户 postgres用户

[root@localhost ~]# su - postgres
Last login: Fri Apr 10 21:04:23 CST 2020 on pts/4
[postgres@localhost root]$

以上

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容