Recursively CHMOD Files

I was moving a bunch of files from one location to another, and it ended up that a ton of those files had the wrong permissions. Now permissions of 755 will generally work for serving an HTML file, but it should probably be served as 644, and since it wasn’t it was bugging me. We’ve already discussed my neuroses, let’s just leave it at that.

So I needed to change a ton of files, and I certainly didn’t want to do it manually. Unfortunately, the -R (recursive, also –recursive) option didn’t seem to be working on my account. I’m not sure exactly why this is, but it didn’t. It worked great for the current directory, but when I’d need to change directories a couple hundred times, that just wasn’t going to cut it.

And that’s when I stumbled across this piece. I was just about to give up, when lo and behold it showed up out of nowhere. A simple one-liner was all it took:

  find . -type f -exec chmod 0644 {} \;

My own command is slightly different than that offered at the link above, as my problem was slightly different. Namely, I wanted to process results that were not directories, and I didn’t want to check for a particular file name. If they were files, I wanted all of them. This little tidbit did the trick.


Posted

in

Comments

2 responses to “Recursively CHMOD Files”

  1. Carl Stephenson Avatar

    Thanks for the “Recursively CHMOD Files” article! I did a backup and needed to change a LOT of file permissions. You saved me a lot of work 🙂

  2. Bob Jordan Avatar

    I stopped by to download the latest version of Notifier and I cannot download anything. Did the recursive CHMOD break something?