linux下使用su切换到其他用户下只能看到sh-4.2$解决

栏目: 编程工具 · 发布时间: 7年前

内容简介:这两天在研究gitlab,在安装gitlab的时候,系统会自动创建一个git用户,当我使用su git切换到git用户的时候发现,无法使用shell命名并且只能看到sh-4.2$,原因是因为git用户目录下缺少用户配置文件解决:

这两天在研究gitlab,在安装gitlab的时候,系统会自动创建一个git用户,当我使用su git切换到git用户的时候发现,无法使用 shell 命名并且只能看到sh-4.2$,原因是因为git用户目录下缺少用户配置文件

linux下使用su切换到其他用户下只能看到sh-4.2$解决

解决:

1:找到git用户下用户目录地址

su git
cd ~
pwd

linux下使用su切换到其他用户下只能看到sh-4.2$解决

2:将 /etc/skel/目录下的文件复制到git用户目录下,并将文件访问权限改成git用户

su root
cd /etc/skel/
cp .bash_logout .bash_profile .bashrc /var/opt/gitlab/
cd /var/opt/gitlab/
chown git:git .bash_logout .bash_profile .bashrc  #这里注意不要将用户目录下所有文件改成git用户,这样可能会出现其他问题

linux下使用su切换到其他用户下只能看到sh-4.2$解决

3:让git用户可以执行shell命令

usermod -s /bin/bash git

这时候切换到git用户就可以使用shell命令并且显示正常

linux下使用su切换到其他用户下只能看到sh-4.2$解决


以上所述就是小编给大家介绍的《linux下使用su切换到其他用户下只能看到sh-4.2$解决》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Foundation Web Standards

Foundation Web Standards

Jonathan Lane、Steve Smith / Friends of ED / 21st July 2008 / $34.99

Foundation Web Standards explores the process of constructing a web site from start to finish. There is more to the process than just knowing HTML! Designers and developers must follow a proper proces......一起来看看 《Foundation Web Standards》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具