How do I list all users with admin rights on Linux? I checked file /etc/passwd/, but I don't know how can I figure out which account is privileged.
First, there is
0), which is and always be the only true admin, or superuser.
However, other users may be given the ability to impersonate
root, and in that way effectively become admins. This can be done with:
su: This command impersonates a user and opens a shell, but you need to know the target user's password. This allows anyone who knows root's password to become an administrator.
sudo: This command impersonates a user and executes a command, but you need to know the invoking user's password, and the invoking user must have sudo privileges. This allows anyone with sudo privileges to become an administrator.
On an Ubuntu system, the root account is generally disabled, which means root doesn't have a password and you can't log into that account, so
su is not available.
root can still be impersonated, however, which means the primary method of being an admin is through the
To find out who generally has sudo privileges, you can view the
sudoers file, which is located at
/etc/sudoers. You might also want to look up the file format in the man pages. By default, Ubuntu has an
admin group, and anyone in that group can use
sudo. Other distributions might have a
sudoers group or a
sudo group or a
staff group. grawity adds that most KDE and Gnome applications use
polkit to manage authorization, which usually uses the
wheel group for administrator privileges. OS X also uses the
wheel group to give admin access to daemons and other system-level tasks, while the
admin group is used to give administrator access to user accounts.
Beyond this, there are a myriad of "partial-admin" things that can be set up. Root is only an "admin" because it inherently bypasses security checks. If a user has specific permissions for a certain function, then they too are an "admin" over that area; For example, just as you are an admin over your home directory, you can make someone an admin over the webserver, or an admin over the video/audio outputs on the computer (Look up the
audio groups, if I remember Ubuntu correctly).
To summarize, there's not exactly an easy way to get a "list of administrators". However, to quickly get most of them:
root, just because.
- Anyone with sudo privileges, or in a group with sudo privileges. Usually anyone in the
sudoersgroups, if they exist.
- Of course, anyone that knows the password to the aforementioned accounts.
To actually find the admin for a group, you would look at the
group- file. This file lists all the admins for each group listed. You can only view the contents of this file if you are an admin elevated through
root. The regular group file as others have mentioned will only list general memberships to such listed groups.
This is how Slackware or other Slackware distros work, but i do recall seeing other distros having these files.