This account is currently not available

在linux中使用su切换到nginx账号的时候出现了This account is currently not available的错误提示。

使用grep nginx /etc/passwd查看用户权限

$ grep nginx /etc/passwd
nginx:x:997:995:nginx user:/var/cache/nginx:/sbin/nologin

这里可以看出,nginx是/sbin/nologin禁止登录的。只要修改这个模式就可以了

$ usermod -s /bin/bash nginx

# 再次查看状态
$ grep nginx /etc/passwd
nginx:x:997:995:nginx user:/var/cache/nginx:/bin/bash

然后就可以用su - nginx切换了

恢复的话改为/sbin/nologin即可

$ usermod -s /sbin/nologin nginx
0%