Stop letting your web directories stay wide open to the world

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

Stop letting your web directories stay wide open to the world

🧩 The Challenge

Dealing with a hacked site because someone blindly ran chmod 777 on the uploads folder makes my blood boil. It’s the fastest way to get a webshell sitting in your public directory while you sleep.

💡 The Fix

Use find to surgically target directories and files separately, setting secure defaults that keep your application functional without inviting script kiddies in.

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

⚙️ Why It Works

Directories need the execute bit to be traversable, but files rarely need write access from the web server user itself. Splitting the command this way ensures you don’t accidentally make every single script on your site world-writable.

🚀 Pro-Tip: If you need a folder for uploads, give ownership to the web user and keep the group and others locked down.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted