Stop chown from being a dangerous foot-gun when symlinks get involved

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

Stop chown from being a dangerous foot-gun when symlinks get involved

🧩 The Challenge

You are trying to fix permissions on a directory tree, but accidentally follow a symlink and end up chowning your entire root filesystem. I’ve seen a junior admin nuke a production server’s system binaries doing exactly this.

💡 The Fix

Use the flags that force the utility to ignore symlinks entirely so you don’t accidentally walk out of your target directory and into a recursive nightmare.

chown -hR user:group /path/to/target

⚙️ Why It Works

Adding the -h flag tells the tool to operate on the symlink itself rather than the target file it points to, effectively keeping your recursive operations safely contained.

🚀 Pro-Tip: Always double-check your path with a dry-run find command before throwing a recursive chown at a production mount.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted