run sudo command with password in one line 1

run sudo command with password in one line

$ echo "your_password" | sudo -S 

Here is what the above code is Doing:
1. echo “your_password” – This will print your password to the terminal.
2. | – This is a pipe. It takes the output of the previous command and uses it as the input for the next command.
3. sudo -S – This will run the command as root. The -S flag tells sudo to read the password from STDIN.

Similar Posts