How do I change permissions recursively?
There is a problem that happens frequently when
- Moving folders from a windows partition,
- Restoring folders from a CD or DVD.
What I usually want personnaly is to restore things so
- directory are readable, writable, and executable for the owner (and the owner only)
- files are readable and writable by the owner only, and not executable by anyone.
Well, it just takes a few commands:
# find all directories (recursively), and give the owner the permission
# to read, write and execute
find ./ -type d -exec chmod u+rwx {} ;
# find all directories (recursively), and remove all right to
# group members and the rest of the world
find ./ -type d -exec chmod og-rwx {} ;
# find all files (recursively), and give the owner the permission
# to read, write but not execute
find ./ -type f -exec chmod u+wr-x {} ;
# find all files (recursively), and remove all right to
# group members and the rest of the world
find ./ -type f -exec chmod og-rwx {} ;
08/2003
Edited and reformated 12/2005
Edited and reformated 12/2005