I want to write a shell script that will require sudo
privilege to do certain task, but also need to change certain configuration as current user. I want to automate the script as much as possible so it does not need any user intervention.
The problem I have is that if I run the whole script as sudo
, I cannot change current user's configuration. But if I just add sudo
to the specific command that require root privilege, I will need to keep input the password because the script is long and sudo
will time out.
Is there a way I can run the script in current user, but keep the sudo
privilege when I need it?