I want to run a command that requires the sudo password say:
sudo apt-get update
Isn't this supposed to work (I have stored the password in a normal text file passwd.txt
):
sudo apt-get update <~/passwd.txt
This is my logic for for why it SHOULD work: when the password is required, the user is asked to input the password from the keyboard. But redirecting the stdin
to read from the passwd.txt
file should work.
Shouldn't it?
Best Answer
sudo
doesn't read password fromstdin
by default. Fromsudo
manpage:So you should run:
Keep in mind that storing passwords in files is not a good practice. You should read: