Changing permissions recursively on files and folders

Changing permissions recursively on files and folders

Permissions. We hate them (as they always stop us from doing what we want) and yet we love them (as they make sure nobody does what we don’t want them to)…

Dealing with sites, files and hosting one cannot live without permissions; and sometimes cannot sleep also because of permissions.

Everybody knows the easy way of bulk-applying permissions:

chmod dagu folder -R

But what happens when you want different permissions on folder than on files – let’s remember folders need to also be executable for its contents to be readable by a user.

Here is where two handy commands come to aid:

#find . -type f -exec chmod 644 {} \;
#find . -type d -exec chmod 755 {} \;

The first one sets permissions recursively for all files in the current folder.

The second one does the same for directories.

Leave a Reply