Vijayan
Vijayan Thanks for stopping by guys! I'm Vijayan and Techpulse is my beloved brainchild. Currently working as a PHP developer in a digital marketing start-up, I'm overly passionate about not just learning new things but also putting those into practice. I swear by a quote I once came across... 'What separates successful people from unsuccessful people is the former's ability to execute'. Feel free to reach out to me if you have any questions, suggestions or feedback. Hoping to see more of you here!

How to avoid sudo password prompt


How to avoid sudo password prompt

Here is the simple tip which gets rid of this password prompt, follow these tweaks if you have a situation where you don’t want to enter the root password while running the sudo command as a non-root user. We can avoid prompts for passwords by giving the sudo password as a standard input to the sudo command, as shown below:

1
echo <password> | sudo -S <command>

For Example:

1
echo 'password' | sudo -S cp wp-config.php bkp-wp-config.php

Here, the echo ‘password’ will send a password to the output, where | will send this as standard input to the sudo command run with the -S parameter.

-S is -stdin, which reads, the password from the standard input.

for more information about sudo, type man sudo

1
man sudo

comments powered by Disqus