Search code examples
macosunixpasswordssudosudoers

Is there a way to automatically pass a password to sudo without having to type it in?


I have a script like this:

echo [password]| sudo -S

rm /Library/Application\ Support/GarageBand
ln -s /Volumes/WD\ Passport/Projects/Other\ Files/GarageBand /Library/Application\ Support/GarageBand

The

sudo -S 

never gets my input. Is there a way to fill the sudo password without having to type it in manually from the console?


Solution

  • Let’s say your password was in the file called password

    Pipe it into sudo -S

    Example:

    echo password | sudo -S rm /path/to/item