Ubuntu: Error using sudo -stdin



Question:

I'm trying to use the -S stdin arg on sudo.

I tried this:

echo 'mypass' | sudo -S cat /etc/shadow  

And

echo 'mypass\n' | sudo -S cat /etc/shadow  

As the man pages suggest to add a newline.

Both won't work. What is wrong?


Solution:1

echo command won't print newlines with the \n sequence. Use printf instead.

printf "mypassword\n" | sudo -S cat /etc/shadow  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »