因为apache的默认shell是/sbin/nologin,所以用su - apache "ls"运行程序的话会提示“This account is currently not available”。
遇到这种情况有解决办法吗?
谢谢!
root如何用apache的用户身份运行脚本
- jiandan23
- 帖子: 86
- 注册时间: 2010-12-17 22:31
- 系统: Mint 19.2
- vickycq
- 帖子: 4507
- 注册时间: 2011-03-20 13:12
- 系统: Debian
- 来自: 山东省寿光县
- 联系:
Re: root如何用apache的用户身份运行脚本
可以 -s 指定 shell
参考 http://serverfault.com/questions/351046 ... ogin-shell
代码: 全选
# cat /etc/passwd | grep sshd
sshd:x:105:65534::/var/run/sshd:/usr/sbin/nologin
# su -c "ls" sshd
This account is currently not available.
# su -s /bin/bash -c "ls" sshd
Apps bin Desktop Downloads etc incoming mnt tmp Videos
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
欢迎所有 Debian GNU/Linux 用户
- jiandan23
- 帖子: 86
- 注册时间: 2010-12-17 22:31
- 系统: Mint 19.2
Re: root如何用apache的用户身份运行脚本
还找到另外一个sudo的办法,总结一下:
方法一:su -s "/bin/sh" apache -c "whoami"
方法二:sudo -u apache whoami
试了一下,两种方法都是可以的
方法一:su -s "/bin/sh" apache -c "whoami"
方法二:sudo -u apache whoami
试了一下,两种方法都是可以的