Shell script to Finding ALL Superuser ( root ) Accounts under UNIX / Linux OSes

In Unix-style computer operating systems, root is the conventional name of the user who has all rights or permissions in all modes (single- or multi-user). The root user can do many things an ordinary user cannot, such as changing the ownership of files and binding to ports numbered below 1024.

It is never good practice for anyone to use root as their normal user account because simple typographical errors in entering commands can cause major damage to the system. It is recommended to create a normal user account instead and then use the su command to switch when necessary. Some use the sudo utility instead, which allows a measure of graduated access. Following script find out all root user account on system.

#!/bin/bash
# Shell script to Finding ALL Superuser Accounts
# Useful to improve system security.
# Copyright (c) 2005 nixCraft
# This script is licensed under GNU GPL version 2.0 or above
# For more info, please visit: 
#            http://cyberciti.biz/shell_scripting/bmsinstall.php
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1}'
Get the latest tutorials on SysAdmin, Linux/Unix, Open Source, and DevOps topics:
CategoryList of Unix and Linux commands
File Management cat
Firewall Alpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilities dig host ip nmap
OpenVPN CentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Manager apk apt
Processes Management bg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searching grep whereis which
User Information groups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPN CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Alamgir Jan 1, 2012 @ 7:58

    Good …very helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.