Interview Prep/Linux/Permissions, ownership, SELinux and mounts

An upload directory is set `2775` and owned by group `web`, but new files still get the user's primary group.

IntermediateTroubleshootingPermissions, ownership, SELinux and mounts
Answer

Likely causes → Files are moved in (keep their group) rather than created there, or the app sets the group explicitly, or the directory was replaced by a deploy without setgid.

Diagnose →

stat -c '%A %U:%G %n' /srv/uploads
ls -l /srv/uploads | head

Fix → Re-apply chmod g+s /srv/uploads, chgrp -R web /srv/uploads; change the app to create files in place, or use a default ACL: setfacl -d -m g:web:rwX /srv/uploads.

Prevent → Enforce directory modes in config management.

All Linux questions Roadmap: Linux

More on Permissions, ownership, SELinux and mounts