我想在 AIX 系统上使用sudo -i
而不是仅仅 来运行命令sudo
。这样,我可以确保任何环境设置都umask
将是我以该命令身份运行的用户的环境设置。
当以这种方式启动的进程生成文件时,这些文件的所有者/组显然会设置为运行该进程的用户的所有者/组。
Sudo 可以选择指定用户(-u)和小组(-G)。但是,当我尝试使用这些参数运行命令时,出现以下错误:
[johndoe@catchyname ~] # sudo -u 'foo' -g 'bar' ls
Sorry, user johndoe is not allowed to execute '/usr/bin/ls' as foo:bar on catchyname.
允许用户在该/etc/sudoers
文件上运行该系统上的任何内容。
我已多次查看过sudo
文档并在互联网上搜索过,但仍然无法让它发挥作用。
我遗漏了什么或者做错了什么?
答案1
man sudoers
说:
first Runas_List indicates which users the command may be run as via sudo's -u option. The second defines a list of groups that can be specified via sudo's -g option. If both Runas_Lists are specified, the command may be run with any combination of users and groups listed in their respective Runas_Lists. If only the first is specified, the command may be run as any user in the list but no -g option may be specified.
并进一步举例说明:
to allow dgb to run /bin/ls with either
the user or group set to operator:
dgb boulder = (operator : operator) /bin/ls