How do I list all sudo users at CentOS server?

There are many groups(root, wheel, adm etc) at server, and have users in it. I am looking an easy way/command to find users in all groups who have sudo access.

Note: My user also have sudo access. And I am using 64-bit CentOS release 5.2 (Final).

  • Why down vote? Is there anything wrong with question?
    – Ahsan
    Jun 3, 2013 at 10:55
  • 2
    What have you tried and why didn't it work? It's probably worth noting that "sudo users" isn't all that accurate as the /etc/sudoers file can allow certain users or groups to run specific commands as root or some other user but not all commands as all users.
    – Ladadadada
    Jun 3, 2013 at 11:16

3 Answers 3


Try this:

for USER in `cut -d: -f1 /etc/passwd`
  sudo -U $USER -l
  • Error: sudo: illegal option -U'`
    – Ahsan
    Jun 3, 2013 at 11:32
  • Unfortunately I didn't try this on CentOS, only on Ubuntu. What version of CentOS are you using?
    – Ladadadada
    Jun 3, 2013 at 11:37
  • 64-bit CentOS release 5.2 (Final). All commands I found over internet are for Ubuntu or other. Those are not working on my CentOS server.
    – Ahsan
    Jun 3, 2013 at 11:40
  • 1
    It's not a Debian/Ubuntu specific addition. It's in the source. You may have better luck with a more recent version of CentOS.
    – Ladadadada
    Jun 3, 2013 at 11:51
  • No way on CentOS 5.2 ?
    – Ahsan
    Jun 3, 2013 at 11:58

What is wrong with sudo cat /etc/sudoers and maybe getent group <groupname> to get usernames of group members?

  • sudo cat /etc/sudoers shows the groups, i didnt find any users in it and also tried your commnad. I am looking easy way/command which list all users who have sudo rights?
    – Ahsan
    Jun 3, 2013 at 11:38

When adding users with sudo permissions on centos7, its advised to add them to the wheel usergroup which by default has sudo permissions with

sudo gpasswd -a <user_name> wheel

Following @Sven 's answer, does the trick for centos7.

getent group wheel
  • That may be a good idea, but doesn't answer the question.
    – RalfFriedl
    Jan 16, 2020 at 10:24

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.