#!/bin/bash # Purpose: Set correct webserver files and dir permissions # Author: Vivek Gite < vivek@nixcraft.com > # This script is released under GPL version 2.0 or above # + Dirs/Subdirs: read-only and execute to others # + Files: read-only permission # Tested on Debian Linux v3/4/5/6 and RHEL v2/3/4/5/6 # ------------------------------------------------------------------------------------------------- _dir="${1:-.}" _fperm="644" _dperm="755" _chmod="/bin/chmod" _find="/usr/bin/find" _xargs="/usr/bin/xargs" echo "I will change the file permission for webserver dir and files to restrctive read-only mode for \"$_dir\"" read -p "Your current dir is ${PWD}. Are you sure (y / n) ?" ans if [ "$ans" == "y" ] then echo "Setting $_fperm permission for $_dir directory...." $_chmod -R "${_fperm}" "$_dir" echo "Setting $_dperm permission for $_dir directory...." $_find "$_dir" -type d -print0 | $_xargs -0 -I {} $_chmod $_dperm {} fi .