Amazon Whenever I execute a command with 'sudo' in Unix I always get a prompt for entering my password. How do I skip entering my password?
SOLUTION
When you are writing a script and in that script would like to execute a command that requires elevated privilege, you'd have issues because you'd need to enter the password afterwords. Suppose the command you want to execute is:
sudo rm *
And your password is 'myPassWord' without quotes, then here's what you do:
echo myPassWord | sudo -S rm *
'-S' is the option provided by 'sudo' command that means it'll read the password from the standard input instead of the terminal device. That's why you can pipe your password via 'echo' and you'll be able to skip the password prompt this way.
Enjoy! Questions? Let me know!
One Minute Information - by
Michael Wen
ADVERTISING WITH US - Direct your advertising requests to Michael
ADVERTISING WITH US - Direct your advertising requests to Michael