How to Change a UID or GID

By Kristen Waters

The Linux and Unix operating systems use positive integers (numbers) to identify users and groups. The "UID" (User Identifier or User ID) is the number that identifies the user. The "GID" (Group Identifier) is the number that identifies a particular group. A user will have only one UID. Every user will belong to a primary group, but may also belong to multiple secondary groups. The "usermod" command is used to change the UID and GIDs for a single user. The "groupmod" command is used to change the GID for an entire group.

Step 1

Open a terminal window. The terminal window is found under "System Tools," "Accessories" or "Utilities" in the main menu.

Step 2

Type the command "su" to switch to the root user.

Step 3

Type the command "usermod -u" to change the UID for a user. Replace "" with the new UID. Replace "username" with correct username. For example, type "usermod -u 1001 bob" to change the UID for the username "bob" to "1001."

Step 4

Type the command "usermod -g" to change the primary GID for a user. Replace "" with the new primary GID. Replace "username" with the correct username. For example, type "usermod -g 500 bob" to change the primary GID for the user "bob" to "500."

Step 5

Type the command "usermod -G," to add the user to any secondary groups for a user. Replace "" and "" with the secondary GIDs. Replace "" with the correct username. For example, type "usermod -G 300,400 bob" to add the user "bob" to the secondary groups "300" and "400."

Step 6

Type the command "groupmod -g" to change the GID for a user. Replace "GID" with the new GID. Replace "groupname" with the correct username. For example, type "groupmod -g 500 admins" to change the GID for the groupname "admins" to "500."

Step 7

Type the command "exit" to close the root user session.