I learned from my earlier question What's the purpose of using `sudo -S` explicitly? that sudo accepts password not from stdin by default.

Why is that? Is it because of some security reason?

1 Answer 1


It's often useful to pipe input into sudo, such as being able to do echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope without the 0 being interpreted as the sudo password. If sudo accepted the password from standard input, that wouldn't work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .