How to Enter Your Password for sudo in a Single Command

lynerlwl

Lyner Lim

Posted on October 26, 2024

How to Enter Your Password for sudo in a Single Command

If you’re using the terminal on Linux or Mac, echo <password> | sudo -S <command>.

If you’re doing this programmatically, for example in Python, os.system(f'echo {password} | sudo -S {command}').

💖 💪 🙅 🚩
lynerlwl
Lyner Lim

Posted on October 26, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related