Linux

BULK LINUX CHMOD COMMANDS FOR FILES & DIRECTORIES

Recently in Ubuntu which I use for my hosting operating system of choice I needed to bulk change permissions on a bunch of folders and files. I needed to set permissions on folders within a WordPress installation to 755 and all files in theme, plugin and asset directories to 644.

While my command line-fu is not very strong, I was able to work it out and I thought I would share my findings here for others.

To bulk change permissions on folders:

find /yourlocationwithfolders -type d -exec chmod 755 {} \;

To bulk change permissions on files:

find /yourlocationwithfolders -type f -exec chmod 644 {} \;

You can use the -R recursive flag with chmod, but it will not allow you to set permissions on all folders and files, but rather on everything (which is rare you would want to set permissions on everything to be the same).

Recent Posts

Unlocking the Secrets of JSON.stringify(): More Than Meets the Eye

JSON (JavaScript Object Notation) is a lightweight data-interchange format widely used in web development. At…

3 months ago

How to Handle AJAX GET/POST Requests in WordPress

AJAX (Asynchronous JavaScript and XML) is a powerful technique used in modern web development that…

4 months ago

Page Speed Optimization: Post-Optimization Dos and Don’ts

Introduction After successfully optimizing your website for speed, it's essential to maintain and build upon…

4 months ago

Ultimate Guide to Securing WordPress Folders: Protect Your Site from Unauthorized Access

Securing your WordPress folders is crucial to safeguarding your website from unauthorized access and potential…

5 months ago

HTML CSS PHP File Upload With Circle Progress Bar

Creating a file upload feature with a circular progress bar involves multiple steps. You'll need…

5 months ago

Using WP Rocket with AWS CloudFront CDN

Integrating WP Rocket with AWS CloudFront CDN helps to optimize and deliver your website content…

5 months ago