How to sudo as another user, without specifying the username

sudo

So I'm currently trying to create a sudoers file, but I ran into something I can't figure out.

The end result I'm looking for is that I want users to be able to do something like:

sudo /usr/sbin/script.pl

But, instead of running as root, I'd like the script to run as "other_user".

I looked into the sudoers file, and I tried adding a line like:

pedro      ALL = (other_user) /usr/sbin/script.pl

But that only works if I specify the user by doing sudo -u other_user /usr/sbin/script.

Is there an (easy) way to have the script run as a specific user, without having to specify it in the command line?

Best Answer

I don't think there is a configuration parameter to do this. You could hack the source code and recompile it. You could also use an alias e.g.

alias sudo='sudo -u pedro'

but then you'd have to remember to out a \ infront of sudo for anything else

\sudo somecommand 
Related Topic