Wednesday, 14 August 2013

why cannot we execute a list of commands as different user without sudo

why cannot we execute a list of commands as different user without sudo

This question has been asked in a different way in other forums. But there
has not been a decent explanation why you cannot do the below in bash.
#!/bin/bash
command1
SWITCH_USER_TO rag
command2
command3
Usually, the suggested way is
#!/bin/bash
command1
sudo -u rag command2
sudo -u rag command3
but why is not possible in bash to change to different effective user id
at some point during bash script execution and execute rest of the
commands as a different user?

No comments:

Post a Comment