Results 1 to 6 of 6
I would like to make a bash script that changes permissions recursively, so as to ease the transition between umasks.
Basically, by default the umask is 022, but I prefer ...
- 04-29-2009 #1
Changing Permissions Recursively
I would like to make a bash script that changes permissions recursively, so as to ease the transition between umasks.
Basically, by default the umask is 022, but I prefer it 077 for my own home directory. I can change it easily enough, but all the files created before I changed it retain a umask of 022.
I would like to be able to change all the files to a permission of 600, and all directories to a permission of 700.
How would I do this?
- 04-29-2009 #2Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
Use the 'find' command:
Code:find /path/to/home -type f -exec chmod 600 {} \; find /path/to/home -type d -exec chmod 700 {} \;
- 04-30-2009 #3
Ah, nice! I didn't think of that.
- 04-30-2009 #4
Just wondering, what does the:
{} \;
do?
- 04-30-2009 #5Linux Newbie
- Join Date
- Mar 2009
- Posts
- 228
The format of find's -exec option is:
-exec command ;
Whenever the string {} is seen within command it is replaced by the current file name being processed.
The semi-colon ( ; ) has to be escaped with the backslash (\) to keep the shell from treating it as the end of the find command.
Look at the find manpage (# man find) for details.
- 04-30-2009 #6
Ah, that is what I figured, but I just wanted to make sure.


Reply With Quote