网站首页技术博客

Linux切换用户

洞天水月2022-03-18 16:38:51281人次阅读
摘要开发过程中经常需要切换用户,比如切换到web的www用户 切换用户使用su命令,例如 su www 但是,在没有设置的情况下,默认www用户是不能登录的,会报下面的错误 [root@iZ2zeeetxecah9u89x7qt0Z kuaipin8]# su www This account is currently not available. 这时候需要编辑/etc/passwd

 

开发过程中经常需要切换用户,比如切换到web的www用户

切换用户使用su命令,例如

su www

但是,在没有设置的情况下,默认www用户是不能登录的,会报下面的错误

[root@iZ2zeeetxecah9u89x7qt0Z kuaipin8]# su www
This account is currently not available.

这时候需要编辑/etc/passwd文件

chenjianfei:x:1000:1000::/home/chenjianfei:/bin/bash
zhengtanyu:x:1001:1001::/home/zhengtanyu:/bin/bash
www:x:1002:1002::/home/www:/sbin/nologin
saslauth:x:989:76:Saslauthd user:/run/saslauthd:/sbin/nologin
mysql:x:1003:1003::/home/mysql:/sbin/nologin

修改www用户的/sbin/nologin 为 /bin/bash

修改后

www:x:1002:1002::/home/www:/bin/bash

wq保存退出

这时就可以切换到www用户了

文章评论