The Curious Website Designer

Bash - How To Recursively CHMOD Files And Folders

Posted by The Curious Website Designer | Posted on Sun 10 Jan 2021

Bash - How To Recursively CHMOD Files And Folders

Occasionally, especially after extracting an archive, the file and folder permissions are not as they should be; I had a recent example where many files were left with 640 permission instead of 644.

As a reminder to myself, here's how to do it.

 

find /path/to/files/* -type f -exec chmod 644 {} \;
find /path/to/files/* -type d -exec chmod 755 {} \;

 

Note the backslash and semi-colon at the end are important. 

Also if you are currently in the folder you wish to start, you can leave out the "/path/to/files/" part

 

 

Related Articles

Bash - How to Send stdout & stderr To a Logfile

Bash - How to Send stdout & stderr To a Logfile

Posted by: The Curious Website Designer
on Sat 28 Apr 2018

Debugging CRON jobs can be quite difficult - there is no visible output, so you don't know if the script failed to run or if the script ran but failed. If it's the latter (ran and failed), you don't get to see any error messages.

Bash - Recursively Removing Files and Folders

Bash - Recursively Removing Files and Folders

Posted by: The Curious Website Designer
on Sun 10 Jan 2021

Another reminder how to perform a routine task from the command line or in a Bash script. This time it's deleting files & folders. Also how to remove a group of files that are older than (x) days.

Tags: bash, chmod