Stop wondering why your app can’t read files it clearly owns

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

Stop wondering why your app can’t read files it clearly owns

🧩 The Challenge

You finally got the permissions set to 644 and the ownership pointing to the right user, but the web server still throws a 403. You’ll spend an hour digging through logs before you realize it’s just the parent directory’s execute bit missing or some obscure SELinux context playing gatekeeper.

💡 The Fix

Use namei to walk the whole path and check the bits, then use restorecon to fix the security labels if your distro likes to get fancy with labeling. This saves you from staring at ls -l output until your eyes bleed.

namei -l /var/www/html/app/config.php
restorecon -Rv /var/www/html/app/

⚙️ Why It Works

Running namei shows you exactly which directory in the chain is blocking access by printing out the permissions for every single component of the path. Once you identify the culprit, the context reset usually clears up any hidden mandatory access control blocks.

🚀 Pro-Tip: If you’re on a RHEL-based system and still stuck, check audit2why; it’ll basically tell you which rule is actually blocking the action.

Linux Tips & Tricks | © ngelinux.com | 9/15/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted