Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Tue, 10 Jun 2003 21:42:20 -0400 (EDT) Message-Id: <200306110142.h5B1gJTq014652@ms-smtp-01.southeast.rr.com> From: Max Polk To: cygwin AT cygwin DOT com Subject: Some useful permission setting scripts I've tried a bunch of things, nothing seems to work better and more cleanly than these few scripts I wrote for setting or resetting file permissions in cygwin on Windows XP, especially when things seem "stuck" or "weird". The order of the chmod and the chown before the cacls command is important. The double quotes are important, especially since there are MANY spaces in filenames in Windows. ---------------------------------------- FILENAME: /usr/local/bin/permission-everyone PURPOSE: Resets permission recursively to be available to everybody USAGE: It takes a while for this to complete if your directory is big, just wait. ---------------------------------------- #! /bin/sh for file in "$@"; do echo "$file" chmod -R 777 "$file" chown -R Administrators:SYSTEM "$file" echo "y" | cacls "$file" /t /g "everyone:f" done ---------------------------------------- FILENAME: /usr/local/bin/permission-bozo PURPOSE: Lets me and WARNING: If you omit "nt authority\system" then services that start at system time can't read your files. WARNING: If you omit "administrators" then if you reinstall Windows, you can NEVER, NEVER, EVER get to the file again, even as administrator! (SOLUTION: use partition magic, convert your drive to "FAT32" drops the bad permission, then convert your drive back to "NTFS" which sets default permissions letting you get to your files again). NOTE: Replace bozo with your user name. ---------------------------------------- #! /bin/sh for file in "$@"; do echo "$file" chmod -R 755 "$file" chown -R Administrators:SYSTEM "$file" echo "y" | cacls "$file" /t /g "nt authority\system:f" "bozo:f" "administrators:f" done ---------------------------------------- FILENAME: /usr/local/bin/permission-bozo-not-recursive PURPOSE: Same as above, but only works on the one file, not recursively ---------------------------------------- #! /bin/sh for file in "$@"; do echo "$file" chmod 755 "$file" chown Administrators:SYSTEM "$file" echo "y" | cacls "$file" /g "nt authority\system:f" "bozo:f" "administrators:f" done ---------------------------------------- FILENAME: /usr/local/bin/permission-strictly-bozo PURPOSE: If you ignore the warnings above, use this to make the files only viewable strictly by bozo. WARNING: See warning above about not letting Administrator in. You've been warned! NOTE: Replace bozo with your user name. ---------------------------------------- #! /bin/sh for file in "$@"; do echo "$file" chmod -R 700 "$file" chown -R Bozo:None "$file" echo "y" | cacls "$file" /t /g "bozo:f" done I grant this to the public domain -- Max Polk (maxpolk AT lycos DOT com) -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/