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

After mounting a new volume over `/var/www/uploads`, the app can no longer write there.

IntermediateTroubleshootingPermissions, ownership, SELinux and mounts
Answer

Likely causes → The new filesystem's root directory is owned by root:root with 755, hiding the old directory's ownership; on SELinux hosts the new mount root has the wrong label.

Diagnose →

ls -ldZ /var/www/uploads
findmnt /var/www/uploads

Fix → chown www-data:www-data /var/www/uploads (on the mounted FS), set the mode, and restorecon -Rv /var/www/uploads.

Prevent → Include ownership and labels in the step that adds a mount.

All Linux questions Roadmap: Linux

More on Permissions, ownership, SELinux and mounts