User Tools

This is an old revision of the document!


Ideas

find . -type f -exec chmod 664 {} \; && find . -type d -exec chmod 775 {} \;
find ./* | while read file; do [[ -f "$file" ]] && chmod 644 "$file"; [[ -d "$file" ]] && chmod 755 "$file"; done

Script

#!/bin/bash

# check if root
if [[ $EUID -ne 0 ]]; then
  echo "This script must be run as root." 1>&2
   exit 1
fi

# check if params
if [ $# -lt 1 ];then
  echo "Usage : chw <FOLDER>"
  exit;
fi

# check for the folder
if [ ! -d "${1}" ]; then
  echo "The folder ${1} does not exist."
  exit;
fi

cd "${1}"
find ./* | while read file; do [[ -f "$file" ]] && chmod 664 "$file"; [[ -d "$file" ]] && chmod 2775 "$file"; done

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information