I have two users on a macos. U1
is a non-admin user and U2
is a admin user.
I cannot add U1
to the sudoers. Is there a way to use U2
to act as if it was U1
issuing sudo <command>
?
My thinking:
U1> su U2
U2> sudo -u U1 <command>
Is this the correct way to achieve the same result as if U1
could issue sudo <command>
?
I tried to set an environment variable as U1
before line 1. and print it out in 2. with sudo -u U1 echo $VAR
and it worked, i get the correct value back. But I am still unsure that's the correct process to install complex packages etc. from U2
on behalf of U1
.
Any corrections/suggestions?