Managing user accounts is a fundamental Linux administration task. Ubuntu 24.04 LTS provides the adduser, usermod, and deluser commands to create, modify, and remove accounts safely.

Tested and valid on:

  • Ubuntu 24.04 LTS

Prerequisites

  • Ubuntu 24.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:

sudo usermod -aG sudo newuser

Verify group membership:

groups newuser

Step 3 – Switch to the New User

Test the account:

su - newuser

Confirm sudo access:

sudo whoami

Step 4 – Modify User Details

Change the login shell:

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 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 home directory and mail spool:

sudo deluser --remove-home newuser

Step 7 – List All Users

View all accounts:

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 24.04 LTS. Always apply the principle of least privilege — only grant sudo access to accounts that genuinely require it.