Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to run commands on an AIX system with sudo -i instead of just sudo. This way I can make sure that any environment settings like umask will be those of the user I'm running the command as.

When the process started this way generates files, those files will obviously have their owner/group set to that of the user the process is run as.

Sudo has the option to specify the user (-u) and the group (-g). However, when I try to run a command using those parameters, I get the following error:

 [johndoe@catchyname ~] # sudo -u 'foo' -g 'bar' ls
Sorry, user johndoe is not allowed to execute '/usr/bin/ls' as foo:bar on catchyname.

The user is allowed to run anything on this system in the /etc/sudoers file.

I have looked through the sudo documentation and searched the internet many a time, but haven't been able to get this to work yet.

What am I missing or doing wrong?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

man sudoers says:

      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.

and further provides an example:

      to allow dgb to run /bin/ls with either
      the user or group set to operator:

       dgb    boulder = (operator : operator) /bin/ls
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.