5 ways to find a Linux user ID (UID) in Ubuntu 20.04

s2 0

The user ID or UID in Linux is a unique unit by which a user is identified on a system. Every user on a Linux system has a dedicated UID. There are several ways to find a Linux user’s UID and we’re going to share all of these ways with you for an Ubuntu or Linux Mint system.

5 ways to find the UID in Ubuntu Linux

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

Method # 1: Using the “id” Command

To use the “id” command to find the UID of the currently logged in user in Ubuntu, you need to run it as follows:

$ id

The UID of our currently logged in user is highlighted in the following figure:

Method # 2: Using the “id” command with username

The “id” command can also be linked to the username of your desired user to get the UID of that user in the following way:

$ id username

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

Find other user 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 to find the UID in Linux Mint 20, you need to run it as follows:

$ 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 with getent

Method # 4: use the lslogins utility

To use the lslogins utility to find the UID in Linux Mint 20, you need to run the following command:

$ lslogins -u

Linux command lslogins

This utility will show you 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 to find the UID of the specified user in Ubuntu in the following way:

$ grep username /etc/passwd

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

Find the UID with the grep command

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

User details from the passwd file

diploma

By choosing a method of your choice in this tutorial, you can find the UID of any user you want while using Ubuntu 20.04. All of the commands and utilities that we used for this tutorial are built in. Hence, you don’t have to waste valuable time installing anything while following this tutorial.

5 ways to find a Linux user ID (UID) in Ubuntu 20.04
Tags: