Sudo is usually used to allow a user to run commands as root, but what happens if you want a user to run a command as another user?
You can use the example below to configure your sudo rule.
[[email protected] ~]$ sudo -u sudoguy whoami
The rule from /etc/sudoers:
bcane ALL=(sudoguy) /usr/bin/whoami, NOPASSWD: ALL
Same thing but instead of bcane the users group:
%users ALL=(sudoguy) /usr/bin/whoami, NOPASSWD: ALL
Benjamin is a Infrastructure and Software Engineer. On this blog he writes about Linux, Docker, Programming as well as other Systems topics.
Learn more about Linux
If you liked this article, check out Benjamin's book: Red Hat Enterprise Linux Troubleshooting Guide. Where you can learn a lot more about troubleshooting Linux systems. This book is filled with tips and techniques he has learned over years of managing mission critical systems.