Streamlining User Identity Migration with UID and GID Synchronization

User & Group Management

Streamlining User Identity Migration with UID and GID Synchronization

🧩 The Challenge

Migrating a user account between two Linux systems often results in file ownership mismatches because the system assigned a different UID/GID on the destination server. Manually finding and updating every file owned by the original ID is error-prone and tedious.

💡 The Fix

Use the usermod command to modify the user’s ID and then use the find utility to recursively locate and update the ownership of all files previously associated with the old ID.

usermod -u 1050 username
find / -uid 1005 -exec chown -h 1050 {} +

⚙️ Why It Works

The usermod command updates the entry in /etc/passwd while the find command performs a bulk filesystem update to ensure that no orphaned files are left behind with the old numeric ID.

🚀 Pro-Tip: Always back up the /etc/passwd and /etc/group files before modifying user IDs to prevent accidental account lockout during identity migrations.

Linux Tips & Tricks | © ngelinux.com | 7/6/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted