Chmod directories only in Ubuntu

From The IT Community
Jump to: navigation, search




You may know this problem. You just uploaded a lot of files in many subdirectories to your server, but now your daemon cannot use them, because the directories have the wrong permission. You could use chmod with the -R parameter, but this would chmod the files as well.


Here is how to chmod directories only in Ubuntu:

Here we use a combination of find and chmod. The first part of the command finds everything from the type d, which stands for directory. The second part changes the actual permission setting of the findings.

  • Go to the directory from where you want to do the search.

Beware: This command searches recursively in every subdirectory below the one you are in.

  • Then enter the following:
find . -type d -exec chmod 755 {} \;

Replace 755 with the permission you want to set.

Of course, the user you are logged in with must have the rights to actually change the permissions.



Was this article helpful? Then please donate to keep The IT Community alive...

If you found this article helpful please share it, comment and help others by writing your own article.






Translate this page: