LinuxTutorial2 min read

How to Create and Manage Users on Linux

Add users, set passwords, manage groups, and grant sudo access on Linux using useradd, passwd, usermod, and related commands.

Developer terminal on a laptop in low light

User Management on Linux

Linux is a multi-user system. Each person (or service) should have their own account. As the administrator, you create and manage these accounts from the terminal.

Creating a New User

Use useradd to create a user. The -m flag creates a home directory at /home/username and -s sets the default shell:

sudo useradd -m -s /bin/bash alice

On Ubuntu you can also use the friendlier adduser command, which walks you through the process interactively:

sudo adduser alice

Setting a Password

A new account has no password by default. Set one with:

sudo passwd alice

To change your own password:

passwd

Granting sudo Access

To let a user run commands as root (with sudo), add them to the sudo group (Debian/Ubuntu) or the wheel group (Fedora/Arch):

# Ubuntu / Debian
sudo usermod -aG sudo alice

# Fedora / Arch
sudo usermod -aG wheel alice

The user needs to log out and back in for the group change to take effect. Verify with:

groups alice

Managing Groups

Create a new group:

sudo groupadd developers

Add a user to a group (-a appends without removing existing groups):

sudo usermod -aG developers alice

List all groups a user belongs to:

groups alice

Deleting a User

Remove a user but keep their home directory:

sudo userdel alice

Remove the user and their home directory:

sudo userdel -r alice

Quick Reference

  • sudo useradd -m -s /bin/bash alice — create user with home dir
  • sudo passwd alice — set password
  • sudo usermod -aG sudo alice — grant sudo
  • groups alice — list groups
  • sudo userdel -r alice — delete user and home