Secure OS Software for Linux
Showing results for 
Search instead for 
Did you mean: 

Root user list

Respected Contributor

Root user list

Hi there,

Is there is a command-line or script available which can generate a report of all accounts with root user equivalent privileges in Linux(SUSE and Redhat) setup, with added information on which machine the id resides., etc?

Esteemed Contributor

Re: Root user list


accounts that privileges equal root have uid 0. So you can find them like

# awk -F: '{ if ( $3==0 ) print $1 " " $5 }' /etc/passwd

this will print accountname "$1" and comment field "$5" of password file foreach uid-zero account.

Put it into a file e.g. "uid0.awk" and execute it on all your systems.

for H in $HOSTLIST; do
scp uid0.awk ${H}:/tmp/
echo "Host: $H"
ssh -x $H "sh /tmp/uid0.awk"

This may be a starting point for your.

Frank de Vries
Respected Contributor

Re: Root user list

Another appoach is to use uname -n
to get the machine name in your script

uname -n
grep :0: passwd | awk -F ":" '{ print $1 '}

I assume you know how to cook the script,
otherwise let us know - we help
Look before you leap
Ivan Ferreira
Honored Contributor

Re: Root user list

>>> all accounts with root user equivalent privileges

This should include a report of SUDO users, and a list of users who knows the root password and can su to root (or member of the wheel group if su has been restricted.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?