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?