How to change UID & GID in Linux for any user

As the commands entered below have the potential to cause inaccessibility to files or data, make sure you have taken a data back up first. Once you have backed up your data, proceed as follows. Do not proceed further if you are not confident or aware of what you are doing. Proceed as below at your own risk.

If you use Ubuntu, open a terminal window, then first make sure you activate the root user as follows:
$ sudo su - <enter>
$ passwd root <enter>

Now restart the computer. Login as any user and open a terminal window. Test if the root user has been activated by typing:
$ su <enter>
Enter the root user password

If you get the # prompt, you are done. To change UID & GID, enter following commands, where;
# usermod -u <newuid> <login> <enter>
# groupmod -g <newgid> <group> <enter>


# find / -user <olduid -exec chown -h <newuid> {} \; <enter>
# find / -group <oldgid> -exec chgrp -h <newgid> {} \; <enter>
# usermod -g <newgid> <login> <enter>

Leave a Reply

  

  

  

Blue Captcha Image
Refresh

*

October 2018
M T W T F S S
« Sep    
1234567
891011121314
15161718192021
22232425262728
293031