Change ownership of all folders and subfolders or files

There are often times the permissions on files get a bit confounded and I wish to change them all the be a certain "number". This is different depending on if they are files or folders (and should never be 777).

Change all directories from the current path

$ find . -type d -exec chmod 775 {} \;

Change all files from the current path

$ find . -type f -exec chmod 664 {} \;

These two commands are a life saver - allowing folders a bit more permission than files so that web scripts can update contents inside. Please be wary of what you set permissions to as it could be dangerous!

This code originates from Stack Overflow

View this post on Github

You might also enjoy…

Mike Street

Written by Mike Street

Mike is a CTO and Lead Developer from Brighton, UK. He spends his time writing, cycling and coding. You can find Mike on Mastodon.