linux - Execute root command with no root user avoiding password prompt -


i have script.sh file executing following command:

chown -r apache:apache /var/www/html/my/data 

if try execute non-root user (username = marco), prompt password halts script waiting input.

i'm trying configure /etc/sudoers file adding following lines, none of them works , i'm prompted sudo password:

marco all=(all:all) nopasswd:/my/directory/structure/script.sh marco all=(all) 

any clue? thank you.

if need root permission run chown, there no need give whole script root permissions. place in script:

sudo chown -r apache:apache /var/www/html/my/data 

and, using sudoedit, add line:

marco all=(all:all) nopasswd:chown -r apache:apache /var/www/html/my/data 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -