Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 PHP 脚本,我需要从命令行以 root 身份运行。
在脚本完成一些关键操作(需要 root 访问权限)后,我想将进程的所有者更改为“nobody”。
用PHP可以吗?我该怎么做?
您可以使用以下功能更改用户/组 ID:
posix_setgid
posix_setuid
posix_setegid
posix_seteuid
如果您需要更改组,您需要先执行该操作。
不,脚本不能将所有权显式更改为 root。