What is UID in Linux, How to Find and Change it

A UID is a unique identification number assigned to every user in a Linux system. The primary role of UID is to identify the user to the Linux kernel. Let's find out where they are stored, and how to change it for a user?

If you have interacted with Linux systems, there is a probability you have come across these two words, UID and GID. If you have no clear idea about them, then follow along with this article.

What is UID in Linux?

A UID is an abbreviation of the word User Identifier, while GID is an abbreviation of the word Group Identifier. In this particular article, we will focus on the User Identifier (UID).

A UID is a unique identification number assigned to every user present in a Linux system. The primary role of the UID number is to identify the user to the Linux kernel.

It is used to manage the system resources that a user has access to in the system. It is one of the reasons for using a unique UID for every user available. Otherwise, if we have two users listed under one UID, then they could both have access to resources meant for the other.

Where to find stored UID?

You can find the UID in the /etc/passwd file, which is the file that also stores all users registered in the system. To view the /etc/passwd file contents, run the cat command on the file, as shown below on the terminal.

List contents of the passwd file
List contents of the passwd file

The /etc/passwd file holds all necessary attributes or basic information about every single user in the system. The data is displayed in seven columns, as listed below. These fields are separated by colons (:). This file also contains system-defined accounts and groups required for proper installation, running, and update of the system.

Column 1 – Name
Column 2 – Password – If the user has set a password on this field, then it is indicated with the letter (x).
Column 3 – UID (User ID)
Column 4 – GID (Group ID)
Column 5 – Gecos – Contain general information about the user and can be empty.
Column 6 – Home directory
Column 7 – Shell – The path to the default shell for the user.

Identify the UID

From the image above, the first user listed on the file is root. Root has overall control over every aspect of the system. The root user is assigned UID Zero (O) and GID (0). The other that follow are the system-defined accounts and groups.

The root user
The root user

One more thing to note is that UID = 0 and GID = 0 are what give the root user all the powers in the system. If you wish to prove so, rename the root to something else like Example_User and create a new root user with a new UID and GID. You will realize that the Example_User will still have elevated privileges despite not having the username root.

As you will also notice from the image, the system-defined accounts and groups that follow the root user have the UID 1,2,3,4,… and so on. It is because most Linux systems reserve the first 500 UID for system users. Other users added with the useradd command are assigned UID from 500. In Ubuntu and Fedora systems, a new user, even one created during the installation process, is given the UID from 1000 and above.

You can see this in the image below, where we have two users. Fosslinux_admin and Tuts.

List UID of current users
Listing UID of current users

The user “tuts” was created during the installation process and is assigned the UID 1000. The other user, “fosslinux,” was added later and was given the UID 1001.

How to find the UID of a User, Group or an account

We have discussed how we can find a UID by displaying the contents of /etc/passwd file. There is a faster and easier way. We will use the id command.

For example, to find the UID of user Fosslinux_admin and Tuts, execute the command below. You might be required to enter the root password.

id fosslinux_admin
id tuts

Use ID command to find ID of users
Use ID command to find the ID of users

We can also run the id command on other groups, as shown below. By executing the id command alone in the terminal, it will display the UID of the current logged in user. See the image below.

List UID of other groups and accounts
List UID of other groups and accounts

How to change UID’s

Suppose you are managing a system with a lot of users, say an organization or institution. If a user left the company, you would probably need to assign the new user the UID of the employee who quit.

Let’s first create a temporary user for this example. We will use the useradd command. You will need to have root privileges. See the command below.

useradd example_user

By running the command id on user example_user, we can see that this new user has the UID 1003

Create user, example_user
Create user, example_user

Now, let’s delete the Fosslinux_admin user who had the UID = 1001 and assign it to our new user. We will use the userdel command to remove the user.

sudo userdel -r fosslinux_admin

Once done that, we will assign our new user – example_user, the UID that belonged to fosslinux_admin. That is UID = 1001. We will do this using the usermod command.

usermod -u 1001 exmple_user

By running the id command on the user, for example, _user, we see that the user now has the UID = 1001.

Change a UID to a new user
Change a UID to a new user.

Now once you have the new user the UID of the old user, you will need to sync these with all other files that belonged to the old user. You can do this by executing the command below.

find / -user [UID_of_old_user] -exec chown -h [new_user] {} \;
sudo find / -user 1001 -exec chown -h user_2 {} \;

Update the newuser with associated files of old user
Update the newuser with associated files of the old user

Create a New User With a Specific UID

Alternatively, we can create a new user with useradd command and assign the user a specific UID. See the syntax below.

sudo useradd -u 1111 user_2

By running the id command on user_2, we see that the user’s UID = 1111.

Create a User with a new UID
Create a User with a new UID


That’s it! Everything you need to know about UID’s in Linux systems. If you think we missed a meaningful concept or need any clarification, don’t hesitate to let us know in the comment section below.

Arun Kumar
Arun did his bachelor in computer engineering and loves enjoying his spare time writing for FOSS Linux. He uses Fedora as the daily driver and loves tinkering with interesting distros on VirtualBox. He works during the day and reads anything tech at night. Apart from blogging, he loves swimming and playing tennis.


Please enter your comment!
Please enter your name here




How to install CMake on Ubuntu

CMake is a cross-platform free and open-source software tool designed to build, test, and package the software. CMake uses a simple platform and compiler-independent configuration files to control the software compilation process.

How to install Lightworks on Ubuntu

Even though Linux may not get a native installer of video editing software like Adobe Premiere or Final Cut Pro, that doesn't mean there are no industry standards tools available. Lightworks is non-linear editing (NLE) video mastering app for Windows, Linux, and macOS. Installing it on Ubuntu is simple due to deb package availability.

How to install DaVinci Resolve on Fedora

Davinci Resolve is a professional application used for color correction, video editing, visual effects, and motion graphics. It is one of the extensively used software by movie industries located in Hollywood.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.

5 Ways to Open a Terminal in Ubuntu

Even though Ubuntu supports many applications with amazing Graphical User Interfaces (GUI), there are always reasons why users prefer using the Terminal to perform different tasks.

How to install Wine on Fedora Workstation

Linux distributions are becoming more and more popular every day, and Fedora Workstation is not left behind. This popularity brings forth the need to run Windows applications on Linux distros like Fedora. Windows has quite some excellent Software that is not available for Linux.


Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

Linux Mint vs. Ubuntu – which is best for you?

The conundrum is that which one among them? The best solution is to try both of them out, and then choose whatever seems to work the best for your needs. But here, we're giving you some distinctions between the both that might make it easier for you to make a choice.

Removing the Virus from a Windows PC with a Ubuntu Live USB drive

In this tutorial, we are going to show you how to clean your Windows machine from infected viruses using an Ubuntu live USB or CD and the ClamAV antivirus. The ClamAV is a free, open-source antivirus that can be used on Ubuntu.

How to clone hard disk on Linux using Clonezilla

Disk cloning refers to the process of copying data from one disk to another, thus creating a one-to-one copy of the drive. Technically, this process is possible using the copy-and-paste method.

VIDEO: MX Linux 19 Features and Desktop Tour

MX Linux is a Linux distribution based on Debian stable and using core antiX components. The distributions MX Tools is very popular among users and combined with other several ready-to-use tools, it is great for users who prefer to tweak their distro to their liking. In this video, we will take you through the features tour showing casing MX Linux 19.