I was running Debian for sometime and in Debian the UID starts at 1000. Now I moved to CentOS 6 and the UID starts from 500. Simply changing the UID/GID seemed like an quick way to get my file permission back in sync.

Here’s how to easily change the UID and GID for a user in Linux.

Check my current UID/GID
[[email protected] ~]# id danesh<br /> uid=500(danesh) gid=500(danesh) groups=500(danesh)

Change my UID to 1000
[[email protected] ~]# usermod -u 1000 danesh

Check my UID/GID again. GID is still 500.
[[email protected] ~]# id danesh<br /> uid=1000(danesh) gid=500(danesh) groups=500(danesh)

Change the GID for my group.
[[email protected] ~]# groupmod -g 1000 danesh

UID and GID now updated.
[[email protected] ~]# id danesh<br /> uid=1000(danesh) gid=1000(danesh) groups=1000(danesh)

This will update the files in your home directory with the correct UID/GID but anything outside you will have to do it yourself.