UNIX: Recursively chmod directories only

After my other post on , I had a few problems with images I copied over from another site. The file permissions were all messed so I did some recursive permission fixes.

I ran this command:
[pre lang=”UNIX”]
chmod -R 644 dir
[/pre]
to fix all the permissions. This still didn’t work because I totally forgot that directories needs to be executable. So I needed to figure if I could just make all the directories executable and I found this command at movabletripe.

[pre lang=”UNIX”]
find . -type d -exec chmod 755 {} \;
[/pre]

[pre lang=”UNIX”]
find . -type f -exec chmod 644 {} \;
[/pre]

The first will set all directories inside “.” directory to 755. The second will set all files inside the “.” directory to 644. This worked perfectly. Thanks movabletripe.

[carousel keywords=”unix, linux, administration” category=”Books” tag=”damnsemi01-20″ showBorder=”True”]

Continue Reading

  • Robert Bredlau

    You could have found the same thing via:
    man find

    • Skye

      Yup. But not everyone knows how to use the man pages.