Reading Time 3
Number of Words 659
User accounts are fundamental to any Linux system: they determine who can log in, what permissions they have (administration, read/write), and what actions they can perform.
Keeping track of which users exist—and removing unused ones—is essential for security and system hygiene.
In 2025, Ubuntu continues using the traditional Linux account management subsystem, meaning files like /etc/passwd and /etc/shadow still play central roles.
Ubuntu Version Context (2025)
-
The most recent release as of 2025 is Ubuntu 25.04 “Plucky Puffin”.
-
Ubuntu 25.04 ships with the Linux 6.14 kernel and GNOME 48.
-
Although the desktop environment, kernel, and features evolve, the fundamentals of user management remain unchanged.
-
The current Long Term Support (LTS) version is 24.04.
Where User Data Is Stored
-
The file
/etc/passwdholds basic account information: username, UID, GID, home directory, login shell, etc. -
The actual password hashes are stored in
/etc/shadow, which is readable only by privileged users. This separation enhances security. -
System tools and utilities often reference both files when verifying identities or resolving user names.
Listing All Users with Details
To view every user entry (system accounts + human users) with full detail:
sudo cat /etc/passwd
Each line corresponds to one user and contains seven colon-separated fields:
-
Username
-
Password placeholder (often
x, indicating/etc/shadowholds it) -
UID (User ID)
-
GID (Group ID)
-
GECOS / Comment / Real Name (optional)
-
Home directory
-
Login shell (e.g.
/bin/bash)
Showing Only the Usernames
If you only want to see a list of usernames without extra fields:
cut -d: -f1 /etc/passwd
Alternatively, using awk:
awk -F':' '{ print $1 }' /etc/passwd
These commands filter out only the first field (the username), making the output clean and easy to read.
Using getent to Query the Passwd Database
Instead of directly reading /etc/passwd, you can use:
getent passwd
This command consults the system’s configured name service switch (NSS) and will also include users from other sources (e.g. LDAP, NIS) if configured.
To list just usernames from getent:
getent passwd | cut -d: -f1
Adding and Removing Users
Adding a User
On a fresh Ubuntu install, you start with one administrative user (the one you created during setup) plus system accounts.
To add a new user:
sudo adduser newusername
You’ll be prompted for a password and optional profile information.
To grant the new user sudo privileges:
sudo usermod -aG sudo newusername
Removing or Disabling Users
To remove a user and their home directory:
sudo deluser --remove-home username
If you prefer to disable the account without deleting files, you can lock it:
sudo usermod --lock username
Or set its shell to /usr/sbin/nologin or /bin/false to prevent login.
Managing Sudo Privileges
-
The file
/etc/sudoersand the/etc/sudoers.d/directory control which users can run commands as root. -
Use
visudoto safely edit the sudoers file. -
Usually, membership in the
sudogroup gives administrative permissions on Ubuntu.
Password and Security Policies
Ubuntu has a minimum password length and basic entropy checks configured in PAM (Pluggable Authentication Modules). To strengthen password policies, you can adjust settings in /etc/pam.d/common-password (for example, using pam_pwquality). documentation.ubuntu.com+1
You may also configure password lifespan, expiration, and aging using the chage command.
GUI-Based User Management (Desktop)
If you are using Ubuntu Desktop:
-
Open Settings → Users.
-
Unlock the settings (enter your password).
-
Click Add User to create new accounts — you can choose standard or administrator privileges.
-
To delete a user, click Remove and decide whether to delete their files or preserve them.
This graphical method is convenient but under the hood it uses the same user database and system commands.
Default Root Account Behavior
-
By default, Ubuntu does not enable login for the
rootaccount. Instead, administrative tasks are performed viasudo. -
If desired, you can set a root password using
sudo passwd root, but enabling direct root login is generally discouraged for security reasons.
Example: Typical /etc/passwd Output
An example of a few lines from /etc/passwd might look like:
root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin alice:x:1000:1000:Alice User:/home/alice:/bin/bash bob:x:1001:1001:Bob User:/home/bob:/bin/bash
Here, alice and bob are human users; root, daemon, etc. are system users with specific roles.
Conclusion
Listing all users and managing accounts in Ubuntu (including the latest 2025 version) remains largely consistent with older releases. You can use commands like cat /etc/passwd, getent, cut, and awk to inspect users. To add, remove, or modify accounts, adduser, deluser, usermod, and visudo are your tools. GUI tools are helpful on desktop systems, but underneath they call the same system APIs and files.