Wednesday, November 19, 2014

Shell script to find all world-writable files and directories on Linux / UNIX system

  1. #!/bin/bash
  2. # Shell script to find all world-writable files and directories on Linux or
  3. # FreeBSD system
  4. #
  5. # TIP:
  6. # Set 'umask 002' so that new files created will not be world-writable
  7. # And use command 'chmod o-w filename' to disable world-wriable file bit
  8. #
  9. # Copyright (c) 2005 nixCraft project
  10. # This script is licensed under GNU GPL version 2.0 or above
  11. # For more info, please visit:
  12. # http://cyberciti.biz/shell_scripting/bmsinstall.php
  13. # -------------------------------------------------------------------------
  14. # This script is part of nixCraft shell script collection (NSSC)
  15. # Visit http://bash.cyberciti.biz/ for more information.
  16. # -------------------------------------------------------------------------
  17. #SPATH="/usr/local/etc/bashmonscripts"
  18. #INITBMS="$SPATH/defaults.conf"
  19. #[ ! -f $INITBMS ] && exit 1 || . $INITBMS
  20.  
  21. [ $# -eq 1 ] && : || die "Usage: $($BASENAME $0) directory" 1
  22.  
  23. DIRNAME="$1"
  24. $FIND $DIRNAME -xdev -perm +o=w ! \( -type d -perm +o=t \) ! -type l -print

0 comments: