Chmod files 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 files have the wrong permission. You could use chmod with the -R parameter, but this would chmod the directories as well, which could be a security issue.

Here is how to chmod files only in Ubuntu:

Here we use a combination of find and chmod. The first part of the command finds everything from the type f, which stands for file. 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 f -exec chmod 644 {} \;

Replace 644 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: