Web permissions
Very simple, but very handy: a script which sets the permissions of all files and directories inside a folder to the right values.
#!/usr/bin/env python
import os,sys
file_permissions = 0644
dir_permissions = 0755
def change_permissions(path):
if not os.path.isdir(path):
os.chmod(path,file_permissions)
else:
os.chmod(path,dir_permissions)
for p in os.listdir(path):
change_permissions(path + '/' + p)
try:
directory = sys.argv[1]
except IndexError:
sys.exit('A DIRECTORY must be provided.')
change_permissions(directory)
Update
Actually, this is much easier:
#!/bin/bash
find $1 -type d -exec chmod 755 {} \;
find $1 -type f -exec chmod 644 {} \;