If you want to run a
sudo command without being prompted to input the password you can do the following command.
echo password | sudo -S rm -rf /opt/jetty/
In the command above we are trying to remove the
/opt/jetty directory using the
rm -rf command. The
-S (stdin) option allow the
sudo command to read password from a standard input instead of a terminal device.
If you want to store the password in a file you can use the
cat command instead of
echo like the following example.
cat password.txt | sudo -S rm -rf /opt/jetty/
Latest posts by Wayan Saryada (see all)
- How do I clear the current command line in terminal? - February 14, 2019
- How do I generate random alphanumeric strings? - February 7, 2019
- Why do I get ArrayIndexOutOfBoundsException in Java? - January 29, 2019