How to Retrieve User IDs in Ubuntu Linux
A User ID (UID) is a unique number that Ubuntu assigns to every account to control access to files and programs. Finding these numbers takes just a few seconds using the built-in Terminal app.
Run the id -u command to instantly check your own UID number, or type getent passwd to view a complete list of UIDs for every account set up on your system.
You can find your user ID by opening the terminal and typing `id`. To see all user IDs, use `lslogins -u` or `getent passwd `.
Get UID for Users on Ubuntu Linux
Ubuntu Linux assigns a User ID (UID) to keep track of each individual account.
Execute the `id` command shown below to find the current user ID.
id
Output resembling this text appears on screen:
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 lets you retrieve user ID Ubuntu details for every account on your system at once. Running this tool in your terminal prints a complete list that pairs every username with its matching numeric identifier so you can check multiple user accounts quickly.
Execute the `lslogins` command below to list all UIDs present on the system.
lslogins -u
The terminal generates lines matching this format:
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
The getent command helps you find the user ID for a specific account on Ubuntu by checking the /etc/passwd file. This utility is the fastest way to look up the numeric identifier for one individual user instead of listing every account on the entire machine.
getent passwd <username>
This command queries information located in /etc/passwd.
Querying the UID for an account named geekrewind requires running the command below.
getent passwd geekrewind
A single line returns containing the user details, where the third column displays the UID.
richard:x:1000:1000:Richard,,,:/home/richard:/bin/bash
Alternative methods exist for retrieving UIDs, but these commands provide a solid starting point for system administration.
Understanding User IDs in Ubuntu helps you manage system access and permissions effectively.
- Understanding the concept of User ID or UID and its importance in Ubuntu Linux
- Learning multiple methods to retrieve User IDs for individual users and all users on the system
- Exploring commands like id, lslogins, and getent to obtain user IDs efficiently
- Enhancing user management and tracking capabilities on Ubuntu Linux through UID retrieval
- Encouraging further exploration and utilization of additional methods for obtaining user IDs or UIDs in Ubuntu Linux
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!