DEV Community

Lyner Lim
Lyner Lim

Posted on • Edited on

Ubuntu - Enter sudo Password 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}').

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay