1

Most user said is easy to pass password for sudo command using this cli

sudo -S <<< "yourpassord" yourcommand

or

echo "yourpassword|yourcommand

Those cli works for a lot of commands(mkdir, touch, etc) but for some commands like su make problems

sudo -S <<< "yourpassword" su - youruser
-su: line 1: youpassword: command not found

echo youpassword|sudo -S su - youruser 
-su: line 1: youpassword: command not found

How to resolve? Actually I use this workaround

echo yourpassword | sudo -v -S
sudo su - youruser #now work because password is in memory

Someone know a better solution?

1 Answer 1

0

No answer, so I put as a temporary solution this one

echo yourpassword | sudo -v -S
sudo su - youruser #now work because password is in memory

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.