Changing UID/GID in CentOS

Digg ThisShare via email
Submit to reddit Share

CentOS/Red Hat/Fedora create users/groups beginning with 500 where all other distros (that I’m aware of) begin with 1000. Since I use the same account throughout all my servers and have shares mounted between them, it is much easier if my UID/GID matches between systems. I have found it rather easy to change on CentOS as long as I don’t have files saved outside my home directory.

Update UID

# id ryan
# usermod -u 1000 ryan
# id ryan

Change GID

# groupmod -g 1000 ryan

When changing the user ID, the users home directory and all files will automatically be updated to the new UID. However, the same is not true when changing the GID. After changing the GID, update group ownership for that users home directory as follows:

ls -l /home
chown -R :ryan /home/ryan
ls -l /home

I also needed to update the passwd file with the new group ID.

Found the basics of my information at nixCraft

Leave a Reply