I have access to another user's account using command:
sudo su - other_user
I do not have enter password. It seems that this is the only command that sudo allows me.
After that I'm able to perform several tasks like file copying and server restarting. I would like to automate those tasks so that a script can be executed by me, which would get other_user's rights and do what it has to do. However,
sudo spawns another shell, which until I exit it blocks script execution. Is it possible to control that shell and to send commands into it from my script?
I tried suggestions from the answers and both these commands:
sudo -u other_user whoami sudo su - other_user -c "whoami"
ask for password.
Unfortunately, I could not find sudoers to look at settings. The situation annoys me a bit because a have privileges to do what I want to, but can't automate that.