DrGlenn
Free Utility by DrGlenn

Fix Permissions

Recursively set directories to 0755 and files to 0644 from the current folder, verify results, and report any misses.

Overview

DrGlenn’s Fix Permissions is a small PHP helper you can drop anywhere you need to normalize permissions. It applies the WordPress-friendly defaults—folders 755, files 644—and then performs a verification pass.

Safe defaults: 755/644 align with common shared hosting and WordPress recommendations.

Why It’s Handy

  • Quickly recover from incorrect recursive chmods.
  • Normalize permissions after migrations or manual uploads.
  • Generate a concise report of items that couldn’t be changed.

Instructions to Install

  1. Create a file (e.g., fix_permissions.php) in the folder you want to normalize.
  2. Paste the PHP code from the section below.
  3. Run it via the browser (https://example.com/fix_permissions.php) or CLI (php fix_permissions.php).
  4. Review the output and fix any items that require elevated privileges.
Note: Some environments require root or sudo to adjust certain paths. If items are reported as unchanged, re-run with appropriate privileges or fix them manually.

Best Practices

  • Run from the lowest folder you need; it traverses downward recursively.
  • Avoid 777; it’s rarely necessary and often unsafe.
  • After use, delete the script from your server.

What the Script Does

Actions

  • Walks all files/directories starting at the script’s location.
  • Sets directory permissions to 0755.
  • Sets file permissions to 0644.
  • Performs a second pass to verify changes.

Output

  • Lists changed items and any that couldn’t be updated.
  • Summarizes totals for files and directories.
Security Reminder: You are encouraged to delete this file after use to avoid security risks.

PHP Script

Place this code in fix_permissions.php (or a name of your choice) and run it from the directory you wish to normalize.

Loading PHP script…
If the code doesn’t appear, ensure fix_permissions_code.txt is present in the same directory as this page.

🚀 Need help fixing your WordPress site?

From infection cleanup to hardening, I can assist.

Visit fixmyhackedwebsite.com for professional WordPress support.

© 2024–2025 DrGlenn. All Rights Reserved.
Disclaimer: This script is provided free of charge without any warranty or claims of fitness. Use at your own risk and as part of a comprehensive security program.