Skip to content
Advertisement

Execute root command with no root user avoiding password prompt

I have a script.sh file executing the following command:

JavaScript

If i try to execute with a non-root user (username = marco), the prompt password halts the script waiting for the input.

I’m trying to configure the /etc/sudoers file adding the following lines, but with none of them works and I’m always prompted for sudo password:

JavaScript

Any clue? Thank you.

Advertisement

Answer

If you only need root permission to run chown, then there is no need to give the whole script root permissions. Place in the script:

JavaScript

And, using sudoedit, add the line:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement