Managing user accounts is a fundamental Linux administration task. Ubuntu 26.04 LTS provides the adduser, usermod, and deluser commands to create, modify, and remove accounts safely.
Tested and valid on:
- Ubuntu 26.04 LTS
Prerequisites
- Ubuntu 26.04 LTS server or desktop
- A user with sudo privileges
- Basic familiarity with the Linux terminal
Step 1 – Add a New User
The adduser command creates the account, sets up a home directory, and prompts for a password:
sudo adduser newuser
Follow the prompts to set a password and optional account details.
Step 2 – Grant Sudo Privileges
Add the user to the sudo group to allow administrative commands:
sudo usermod -aG sudo newuser
Verify the group membership:
groups newuser
Step 3 – Switch to the New User
Test the account by switching to it:
su - newuser
Confirm sudo access:
sudo whoami
Step 4 – Modify User Details
Change the user’s login shell (example: switch to bash):
sudo chsh -s /bin/bash newuser
Lock or unlock an account:
sudo passwd -l newuser # lock
sudo passwd -u newuser # unlock
Step 5 – Remove Sudo Privileges
Remove the user from the sudo group when elevated access is no longer needed:
sudo deluser newuser sudo
Step 6 – Delete a User
Remove the account but keep the home directory:
sudo deluser newuser
To also remove the home directory and mail spool:
sudo deluser --remove-home newuser
Step 7 – List All Users
View all accounts on the system:
cut -d: -f1 /etc/passwd
List only users with login shells:
grep -v 'nologin|false' /etc/passwd | cut -d: -f1
Conclusion
You can now add, modify, and remove user accounts on Ubuntu 26.04 LTS. Always apply the principle of least privilege — only grant sudo access to accounts that genuinely require it.