5 Ways to find a Linux User ID (UID) in Ubuntu 20.04

The User ID or UID in Linux is a unique entity through which a user is identified on a system. Every user on a Linux system has a dedicated UID. There are several ways of finding the UID of a Linux user and we are going to share with you all those ways for an Ubuntu or Linux Mint system.

5 Ways of Finding the UID in Ubuntu Linux

There are five main methods for finding the UID in Linux Mint 20 which are as follows:

Method # 1: Using the “id” Command

For using the “id” command to find the UID of the currently logged in user in Ubuntu, you have to execute it in the following manner:

$ id

Ubuntu ID command

The UID of our currently logged in user is highlighted in the image shown below:

Result of the id command in Linux

Method # 2: Using the “id” Command with Username

The “id” command can also be paired up with the username of your desired user to get that user’s UID in the following manner:

$ id username

Replace username with the name of the user whose UID you want to find out.

Find other users UID

The UID of our specified user is shown in the image below:

UID of another Linux User

Method # 3: Using the “getent” Command

To use the “getent” command for finding the UID in Linux Mint 20, you will have to execute it in the following manner:

$ getent passwd username

Replace username with the name of the user whose UID you want to find out.

Linux getent command

The UID of our specified user is shown in the image below:

Find UID using getent

Method # 4: Using the “lslogins” Utility

For using the “lslogins” utility to find the UID in Linux Mint 20, you will have to execute the following command:

$ lslogins -u

Linux lslogins command

This utility will present you with a list of all of your system users along with their respective UIDs as shown in the image below:

Using lslogins

Method # 5: Using the “grep” Command

The “grep” command can also be used for finding the UID of the specified user in Ubuntu in the following manner:

$ grep username /etc/passwd

Replace username with the name of the user whose UID you want to find out.

Find UID using grep command

The UID of our specified user is shown in the image below:

User details from passwd file

Conclusion

By picking out any method of your choice from this tutorial, you will be able to find the UID of any user you want while using Ubuntu 20.04. All the commands and utilities that we have used for this tutorial are built-in. Therefore, you will not have to waste your precious time in installing anything while following this tutorial.