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

After restoring `/etc/shadow` from backup on an SELinux system, nobody can log in and logs show `pam_unix(sshd:auth): authentication failure`.

AdvancedTroubleshootingPermissions, ownership, SELinux and mounts
Answer

Likely causes → The restored file has the wrong SELinux label (or wrong mode), so login processes can't read it.

Diagnose → From console or rescue:

ls -lZ /etc/shadow            # expect ----------  root root system_u:object_r:shadow_t
sudo ausearch -m AVC -ts today | grep shadow

Fix → restorecon -v /etc/shadow and chmod 000 /etc/shadow (RHEL) or 640 root:shadow (Debian). If you can't log in at all, boot with rd.break or rescue media, fix the file and touch /.autorelabel.

Prevent → Restore system files with tools that keep xattrs (tar --selinux, rsync -X) and always run restorecon after.

All Linux questions Roadmap: Linux

More on Permissions, ownership, SELinux and mounts