Run sudo command by specifying the password in the same line:
echo "pass" | sudo -S ls
For example let's change user password with no interaction:
echo "pass" | sudo -S bash -c "echo -e 'newpass\nnewpass' | passwd username"
#cli #terminal #linux #ubuntu #sudo #tips