Site icon New Generation Enterprise Linux

Stop fighting directory bit rot with chmod’s X flag

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

Stop fighting directory bit rot with chmod’s X flag

🧩 The Challenge

You know that feeling when you try to fix permissions on a massive nested project folder and accidentally make every single file executable? I’ve spent way too many nights fixing that exact mess.

💡 The Fix

Use the capital X flag with chmod instead of the standard x to perform conditional execution changes that keep your files safe while fixing your directory access. It basically checks if the file is a directory or already has execution bits before touching it.

chmod -R u+X,go-w /path/to/your/web/root

⚙️ Why It Works

By using the capital X, the command only adds the execute bit to directories and to files that already have some sort of execute permission set. It saves you from turning your plain text configuration files into dangerous executable scripts by accident.

🚀 Pro-Tip: Always run it with -v first if you want to see exactly what you’re about to break.

Linux Tips & Tricks | © ngelinux.com | 7/17/2026

0 0 votes
Article Rating
Exit mobile version