【Linux使用及问题解决】用户登录时显示 -bash-4.2$ 问题


集群的普通用户在登录时,会出现 -bash-4.2$ 的状态

 

[html]  view plain  copy
 
  1. [root@dl2 home]#su hx  
  2. bash-4.2$  

 

查看 /etc/passwd 文件,显示用户 hx 的信息

 

[html]  view plain  copy
 
  1. hx:x:1002:1002::/home/hx:/bin/bash  

 

查看 /home目录下没有用户 hx 的目录

 

[html]  view plain  copy
 
  1.   
 
[html]  view plain  copy
 
  1. [root@dl2 home]#ls  

 

 

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

 

[html]  view plain  copy
 
  1. [root@dl2 home]$ cd /etc/skel/  
  2. [root@dl2 skel]$ ls -a    
  3. . ..  .bash_logout  .bash_profile .bashrc  .mozilla    



 

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

 

[html]  view plain  copy
 
  1. [root@dl2 home]#mkdir hx  
  2. [root@dl2 home]#ls  
  3. hx  

 

 

但这个目录是新建的,缺少用户环境配置文件,那么复制/etc/skel这个目录的文件到/home/hx中

 

[html]  view plain  copy
 
  1. [root@dl2 home]$ cp /etc/skel/.bash_logout  /home/hx/    
  2. [root@dl2 home]$ cp /etc/skel/.bash_profile /home/hx  
  3. [root@dl2 home]$ cp /etc/skel/.bashrc  /home/hx   

 

 

再次登录

 

[html]  view plain  copy
 
  1. [root@dl2 home]#su hx  
  2. [hx@dl2 home]  

 

 

解决


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM