Linux CentOS下shell显示-bash-4.1$ 不显示用户名和主机名的解决方法linux
CentOS下新增长一个用户,登陆进去会发现shell脚本信息没有显示用户名和主机名,反而显示的是-bash-4.1$,显示shell
[skyuser2@VM_158_86_centos ~]$ su - skyuser1 Password: Last login: Thu May 23 16:49:50 CST 2019 on pts/0 Last failed login: Thu May 23 16:50:48 CST 2019 on pts/0 There was 1 failed login attempt since the last successful login. welcome to my world.please smile -bash-4.2$
而不是咱们常常看到的username@hostname$的组合,看起来特别别扭不舒服。
问题的缘由是由于没有配置.bash_profile的问题,或者说没有这个文件的问题,能够经过配置或者新建这个文件来解决问题。vim
解决方案:
1.在新建用户的~目录下新建或者更改.bash_profile;这个过程当中可能须要root用户来新建或者修改centos
2.在.bash_profile中添加如下内容:export PS1='[u@h W]$'bash
3.在新建用户下运行一下命令:source ~/.bash_profilecode
这样就能够正常显示用户名和主机名了ast
[root@VM_158_86_centos ~]# cd /home/ [root@VM_158_86_centos home]# ls linux-nice project skygroup skyuser1 skyuser2 skyuser3 skyuser4 skyuser5 wuyuhong [root@VM_158_86_centos home]# cd skyuser1 [root@VM_158_86_centos skyuser1]# ls [root@VM_158_86_centos skyuser1]# vim .bash_profile [root@VM_158_86_centos skyuser1]# su - skyuser1 Last login: Thu May 23 16:50:55 CST 2019 on pts/0 welcome to my world.please smile [skyuser1@VM_158_86_centos ~]$source ~/.bash_profile [skyuser1@VM_158_86_centos ~]$su - skyuser1 Password: Last login: Thu May 23 16:56:59 CST 2019 on pts/0 welcome to my world.please smile [skyuser1@VM_158_86_centos ~]$