How to (sudo or su) to another user
I want to allow user1 to change to user2 with no password guestions. What I have to write into sudoers file?
I have a program. User1 start to run it. In the halfway on program there is function which references into files which user2 owns. I would like change to user2 before we execute this function.
I have this command before function:
system("sudo su - user2");
But now I don't know what I should write into sudoers file?. program always ask me to write password when I program executes this system command.
I have tried to write this in my sudoers file, but this wont work. It still ask's me to write password
[B]user1 machine = (user2) NOPASSWD:ALL[B]