Site icon New Generation Enterprise Linux

Stop letting developers break your permissions with chmod -R 777

Permissions & Security (Chmod/Chown/ACLs/SELinux/AppArmor)

Stop letting developers break your permissions with chmod -R 777

🧩 The Challenge

You know that feeling when a junior dev realizes a script is failing, gets frustrated, and just runs a recursive chmod 777 on the entire web directory? I’ve spent entire weekends untangling the mess that leaves behind when services start throwing 500 errors because the files are world-writable.

💡 The Fix

Instead of letting them play god with directory bits, use the find command to specifically target directories or files and force them back to sane permissions without nuking your security model. This lets you surgically correct the rot without exposing your private configuration files to the world.

find /var/www/html -type d -exec chmod 755 {} \;
find /var/www/html -type f -exec chmod 644 {} \;

⚙️ Why It Works

By separating the search for directories from files, you ensure that executable bits are kept where they belong and stripped away from plain data. It targets only the nodes you specify, which keeps you from accidentally touching something that needs restricted access.

🚀 Pro-Tip: Alias these to fix-perms in your .bashrc and stop them before the security audit finds out.

Linux Tips & Tricks | © ngelinux.com | 8/11/2026

0 0 votes
Article Rating
Exit mobile version