This article describes the steps you can take to get a user ID or UID in Ubuntu Linux.
Every user on a Ubuntu Linux system is assigned a unique user ID or UID. A UID is a numeric value defined by the system to identify users.
No two users will share the same UID on Ubuntu Linux. On a Ubuntu Linux system with multiple users, UID can be a handy way to manage and track users.
Each user can get their UID simply by running the command id. That is the simplest way to view one’s UID on Ubuntu Linux.
However, there are multiple ways to get UIDs for all users, and the steps below show you how.
Get UID for Users on Ubuntu Linux
As described above, A UID is a numeric value the system defines to identify users. UID can come in handy when managing and tracking users on Ubuntu Linux.
To get your user ID, run the id command shown below.
The command above should output a similar line as the one below.
uid=1000(richard) gid=1000(richard) groups=1000(richard),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),134(lxd),135(sambashare)
Use the lslogins command to find the User ID
The lslogins command helps you find multiple users’ user IDs or UIDs. When you use the lslogins command with the -u option, it lists all users’ IDs on the system.
Run the lslogins command below to list all UIDs on the system.
The command above should display similar lines as below.
UID USER PROC PWD-LOCK PWD-DENY LAST-LOGIN GECOS 0 root 205 0 1 root 1000 richard 80 09:41 Richard
Get User IDs using the getent command
Another tool or utility to display a user ID or UID is the getent command. Use the command format below to see a user ID or UID.
getent passwd <username>
The command display UID for users by reading the contents of /etc/passwd.
For example, If you want to know the UID of the user named geekrewind, you will run the command below.
getent passwd geekrewind
The command should output a single line containing the UID for the users. The third column is the UID of the user.
There could be other ways to get a user ID or UID that are not listed above. However, the steps above should be a good starting point.
This post showed you how to list a user ID or UID on Ubuntu Linux. Please use the comment form below if you find any errors above or have something to add.