Recipe 9.4 Finding Superuser Accounts

9.4.1 Problem

You want to list all accounts with superuser access.

9.4.2 Solution

$ awk -F: '$3 == 0 { print $1, "is a superuser!" }' /etc/passwd

9.4.3 Discussion

A superuser, by definition, has a numerical user ID of zero. Be sure your system has only one superuser account: root. Multiple superuser accounts are a very bad idea because they are harder to control and track. (See Chapter 5 for better ways to share root privileges.)

Numerical user IDs are stored in the third field of each entry in the passwd database. The username is stored in the first field. Fields are separated by colons.

9.4.4 See Also


    Chapter 9. Testing and Monitoring