The usermod command
A user identifier must be unique to each user and cannot be the number 0, which is reserved for the superuser (root). There are also a group of UIDs that the system reserves for system accounts. Each Linux distribution and Unix variant will have a different group of numbers that are reserved, Red Hat reserves the numbers 1-499, Debian reserves the numbers 1-999. In the past, the nobody user was assigned the UID 32767, which was the largest possible value, but that has changed in some systems. To be on the safe side, it is a good idea to start user UIDs at 1000.
When you have only one Linux machine either as a desktop or a server, the system will create a unique UID for each user. However, when you have multiple Linux and Unix based machines working together, the UID may become important. For instance, creating an NFS server for both Linux and Mac machines may cause problems because the user UIDs start at different numbers (Mac starts it’s UIDs at 500, and Linux at 1000). UIDs also become important when using kerberos for log in authentication.
You can see the UIDs and GIDs (group identifiers) of the system’s users with the command:
If you want to view what groups the user belongs to, add the -a option:
You can also view the UID of the users through the GUI by choosing the “Users and Groups” option under the System menu. However, changing a UID is something that must be done at the command line.
The usermod command allows you to change the parameters set for existing users. It is often used for changing a username, the groups a user belongs to, the user’s default shell, the user’s default home directory, and, of course the UID for the user. The usermod command has the following format:
usermod [options] login
For the purposes of changing the UID, the command is:
usermod -u login
If you are creating a new user, you can specify the UID in the useradd command.
useradd -u -g -c <“Full Name”> -d -m login
The usermod command has many other options for modifying user accounts. Together with the useradd command, it is one of the most used commands in Linux system administration. The usermod and useradd man pages will give you more information on both commands.