Recursive chmod

My music collection is complicated, I rip my CD’s on a Linux server, FTP them to a Windows server. Manipulate ID tags and filenames using various means, then FTP them back again in order to play them through my Squeezebox. This recently caused me grief when I used an incorrect umask on a massive transfer, resulting in incorrect file permissions on directories and files.

Using recursive chmod to correct this is tricky as file and subdirectory permissions need to be different, in my case, 644 for files and 755 for directories. These two commands solve the problem:

find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
This entry was posted in Debian. Bookmark the permalink.

2 Responses to Recursive chmod

  1. Using the world’s best shell, zsh (http://www.zsh.org) you could have used: chmod 755 **/*(/) and chmod 644 **/*(.)

    :-)

  2. Steve Crook says:

    Hi Jens,

    Thanks for that info. I’ve never bothered swapping shell until your comment prompted me to try out zsh.

    First things first, get the prompt looking nice. :-)
    Next, figure out the globing. Impressive!
    The completion options look good too although I haven’t dug into them yet.

    Makes me wonder why more distros don’t make this the default login shell. I think I’ll be sticking with it.

Leave a Reply