Wednesday, November 19, 2014

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.
  1. #!/bin/bash
  2. # Shell script to Finding ALL Superuser Accounts
  3. # Useful to improve system security.
  4. # Copyright (c) 2005 nixCraft
  5. # This script is licensed under GNU GPL version 2.0 or above
  6. # For more info, please visit:
  7. # http://cyberciti.biz/shell_scripting/bmsinstall.php
  8. # -------------------------------------------------------------------------
  9. # This script is part of nixCraft shell script collection (NSSC)
  10. # Visit http://bash.cyberciti.biz/ for more information.
  11. # -------------------------------------------------------------------------
  12. grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1}'

0 comments: