Bash不能充当nobody和nogroup?

Tho*_*ner 12 shell bash users privileges

我有一个由nobody:创建的日志文件nogroup,这是记录到的活动,我想模拟向该日志文件添加一条消息。我的第一个想法是:

$ sudo su nobody
This account is currently not available.
Run Code Online (Sandbox Code Playgroud)

小智 22

您有一个更简单的解决方案,只需运行:(su -s /bin/bash nobody替换/bin/bash为您选择的外壳)。

This account is currently not available.错误是由于nobody用户默认 shell 是/usr/sbin/nologinsu -s强制系统使用另一个 shell。


Tho*_*ner 10

一个电子邮件线程:

.. 指出sudo -u nobody [cmd ...]可以使用:

(结合How to append to a file as sudo的技巧)

echo "Hello World" | sudo -u nobody tee -a /tmp/logfile.log
Run Code Online (Sandbox Code Playgroud)