Normally i would google, but I did not know how to google the problem I am facing now also being a newbie in shell scripting.
Okay, the requirement is
user1 has sudo rule to su - user2(NO PASSWORD) and user2 has will be able to sudo certain commands
so following works fine from command prompt
user1@host] sudo su - user2
the above command opens up a new shell, logging me in as user2
user2@host] sudo cmd1
user2@host] sudo cmd2
user2@host] sudo cmd3
How would I achieve the above using a shell script?
I have tried putting following commands in a shell script
sudo su - user2 -c "sudo cmd1" (this prompts me for a password though I have a sudo rule to not prompt for one.)
sudo su - user2 (this gets me out of the shell and takes me to "user2@host]")
none works for me.
Any help on this would be greatly appreciated.