1

Can anyone tell me why this does not work?

test:~ test$ echo 123 | su root
su: Sorry

Thanks

  • But why the echo? – Matteo Oct 1 '15 at 10:39
  • I want to be able to delete a few files that require admin access. However the current logged in user is a standard user. So, I need to login as a different user then run the commands. Unless there is a better way? – user2720970 Oct 1 '15 at 10:51
  • If you put the password into a script, you can as well tell the user. Piping passwords into su doesn't work because su always requires manual input for the password – nohillside Oct 1 '15 at 10:57
  • You may want to look into sudo to accomplish this. If you need help in setting it up, please ask a new question stating the problem in more detail. – nohillside Nov 12 '15 at 14:43
  • I need to understand more what you try to achieve for better helping you. Why can't you use sudo? With a proper sudo configuration, you could run any command as root, if you like to. The other way round - if you are familiar with Secure Shell (ssh), you could put your public key into root's authorized keys file and also could execute commands as root. There is really no need for putting a password in clear text into any sort of file... – Garex Nov 12 '15 at 14:48
2

Although the man page for su doesn't state it explicitly, the required password must always be typed manually, it cannot be piped into su.

It has something to do with security ;-)

You must log in to answer this question.

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