I need a shell (ksh) script that can be executed locally on a box that will return a list of users who have sudo access to a server and what commands they can run.

For example I want to know that user “mfly” can run /etc/init.d/mysqld.

I'm trying to make this as system agnostic as possible as I'm working with everything from Solaris 9 to HP/UX as well as Debian based systems. If I can get a lead into the right direction on what system, I'm sure I can make it portable though.


When a user invokes sudo -l it lists what sudo will allow them to do, so you could have a script ran as root that bumps through /etc/passwd and sudo's to each user, invoke the sudo -l, directing the output to /tmp/${USER}_sudo_i_can_do.txt

But if you don't have root access, you won't be able to do what you want to do; the list of permissions is readable only by root. And a user can see only their own permissions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.