4

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).

Ahsan
  • 151
  • 1
  • 1
  • 6
  • Why down vote? Is there anything wrong with question? – Ahsan Jun 03 '13 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 03 '13 at 11:16

3 Answers3

5

Try this:

for USER in `cut -d: -f1 /etc/passwd`
do
  sudo -U $USER -l
done
Ladadadada
  • 26,337
  • 7
  • 59
  • 90
2

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

Sven
  • 98,649
  • 14
  • 180
  • 226
  • `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 03 '13 at 11:38
1

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
Ricoh
  • 11
  • 2