Permissions & Security (Chmod/Chown/ACLs/SELinux/AppArmor)
Stop your files from inheriting the wrong owner when someone does a reckless copy
đź§© The Challenge
Everyone has dealt with a dev who copied a config file over to a shared web directory and suddenly the server can’t read it anymore because it kept the user’s private UID. It’s a classic headache that breaks production apps in five seconds flat.
đź’ˇ The Fix
You can use the force of the parent directory’s setgid bit to ensure every new file inside a specific folder automatically adopts the group ownership of that folder instead of the person who created it.
chmod g+s /path/to/shared/directory
⚙️ Why It Works
Setting this bit on a directory forces the effective group ID of any new file or sub-directory to match the directory itself, effectively bypassing the default behavior where files always belong to the user’s primary group.
🚀 Pro-Tip: Combine this with a tight umask in the project’s profile to keep things tidy from the start.
Linux Tips & Tricks | © ngelinux.com | 7/21/2026
