Why is it dangerous to give a new employee the same UID and GID as someone who has just left?
Files store only the number, so the new employee becomes the owner of everything the old one left behind and gets all of that access at once.
Ownership is the UID stored with each file, not the user name. If UID 1004 belonged to the leaver and is handed out again:
- every file, directory and mailbox still owned by 1004 now belongs to the new person, including confidential data, private keys and scripts,
- group memberships tied to the GID carry over too,
- logs and audit trails can no longer tell the two people apart, which breaks accountability.
It is a silent breach of least privilege and of confidentiality: nobody granted the access, it simply arrived with the number.
Good practice: do not reuse UIDs. When someone leaves, disable the account, then archive their files or give them to a named owner, and only then delete it. Central identity management (one directory, IDs derived automatically) makes collisions like this much less likely.
Go deeper:
Wikipedia: Principle of least privilege โ the principle a reused UID silently breaks.