Skip to content
Follow
Ubuntu Linux

How to Retrieve User IDs in Ubuntu Linux

Richard
Written by
Richard
Jan 5, 2023 Updated Aug 13, 2026 2 min read
How to Use Sticky Notes in Windows 11
How to Use Sticky Notes in Windows 11

A User ID (UID) in Ubuntu Linux is a unique number that the system assigns to every account to control access to files and programs. Finding these numbers takes just a second using the built-in terminal.

Run the `id -u` command in your terminal to instantly see your own UID number. Type `getent passwd` to view a complete list of UIDs for every account set up on your Ubuntu system.

⚡ Quick Answer

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.

💻Code
id

Output resembling this text appears on screen:

💻Code
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

Running `lslogins -u` in the terminal outputs a comprehensive list pairing usernames with their corresponding UIDs. This command retrieves user IDs for multiple people on the system at once.

Execute the `lslogins` command below to list all UIDs present on the system.

💻Code
lslogins -u

The terminal generates lines matching this format:

💻Code
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` utility checks system user details stored in the /etc/passwd file to locate a single account's identifier. Run `getent passwd ` to find a specific user's ID, substituting `` with the actual login name.

💻Code
getent passwd <username>

This command queries information located in /etc/passwd.

Querying the UID for an account named geekrewind requires running the command below.

💻Code
getent passwd geekrewind

A single line returns containing the user details, where the third column displays the UID.

💻Code
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.

Conclusion:

  • 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

Where is the user ID stored in Linux?

UID (User Identifier) in Linux is a unique numerical value assigned to each user account, helping identify and differentiate users. The UID is stored in the system's user database, usually in the /etc/passwd file, along with other user details.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to List User Profiles and Accounts in Windows 11
Windows How to List User Profiles and Accounts in Windows 11
How to Install GNOME Desktop on Ubuntu 24.04
Ubuntu Linux How to Install GNOME Desktop on Ubuntu 24.04
How to Install KDE Desktop on Ubuntu 24.04
Ubuntu Linux How to Install KDE Desktop on Ubuntu 24.04

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *