How to Add and Delete Users on Debian 13

Adding and removing users is one of the first tasks when setting up a Debian system.
Debian, like other Linux distributions, is a multi-user OS. Each user can have separate permissions, shell settings, and access to CLI and GUI apps.
Knowing how to add and remove users is a basic Linux skill. It keeps the system secure by making sure only the right accounts can access protected resources and run administrative commands.
This article describes how to add and remove users on Debian 13. The same steps work on older Debian releases such as Debian 12 and 11.
Quick Reference
| Command | Description |
|---|---|
sudo adduser username | Create a new user |
sudo deluser username | Delete a user |
sudo deluser --remove-home username | Delete user and home directory |
sudo usermod -aG sudo username | Grant sudo privileges |
sudo passwd username | Change user password |
sudo usermod -L username | Lock password authentication |
sudo usermod -L -e 1 username | Lock and expire user account |
sudo usermod -U -e "" username | Unlock user account and clear expiry |
id username | Show user information |
Prerequisites
You need administrative privileges to add or remove user accounts on your Debian system. See our guide on creating a sudo user on Debian .
How To Add a User in Debian
In Debian, there are two command-line tools that you can use to create a new user account: useradd and adduser.
useradd
is a low-level command-line tool for creating user accounts. adduser is a Perl-based wrapper around useradd that provides an interactive prompt and sensible Debian defaults.
To create a new user account named leah using the adduser command, you would run:
sudo adduser leahAdding user `leah' ...
Adding new group `leah' (1001) ...
Adding new user `leah' (1001) with group `leah (1001)' ...
Creating home directory `/home/leah' ...
Copying files from `/etc/skel' ...You will be asked a series of questions. Entering and confirming the password is required; all other information is optional.
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for leah
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n]
Adding new user `leah' to supplemental / extra groups `users' ...
Adding user `leah' to group `users' ...On the last prompt, confirm that the information is correct by pressing Enter.
The command creates the new user’s home directory and copies files from /etc/skel to that directory. The user can write, edit, and delete files inside their home directory.
Grant Sudo Privileges
On Debian, members of the sudo group can run commands with sudo
privileges. To give a newly created user administrative rights, add the user to the sudo group
:
sudo usermod -aG sudo leahAlways include the -a flag when adding a user to a new group. Without it, usermod overwrites the existing secondary groups instead of appending to them, which can lock the user out of groups they still need.
The new group membership only takes effect the next time the user logs in. You can confirm it with the groups command:
groups leahleah : leah sudo usersHow To Delete a User in Debian
If the user account is no longer needed, you can delete it with userdel
or deluser. Generally, it is better to use the deluser command as it is more user-friendly than the low-level userdel.
To delete a user, without removing the user files, run:
sudo deluser leahRemoving crontab ...
Removing user `leah' ...
Done.When removing a user account with deluser, the user’s home directory and mail spool are not removed. To remove those directories, invoke the command with the --remove-home flag:
sudo deluser --remove-home leahLooking for files to backup/remove ...
Removing files ...
Removing crontab ...
Removing user `leah' ...
Done.How to List Users
To list all users on the system, use the getent command (see list users in Linux
for more options):
getent passwdThis displays all user accounts, including system users. To list only regular users in the common human-user UID range:
getent passwd | awk -F: '$3 >= 1000 && $3 <= 60000 {print $1}'How to Check User Information
To view information about a specific user, use the id command:
id leahuid=1001(leah) gid=1001(leah) groups=1001(leah),27(sudo),100(users)How to Change User Password
To change a user’s password, use the passwd
command:
sudo passwd leahThe command will prompt you to enter and confirm the new password.
How to Lock and Unlock a User
To lock password authentication for a user account, use usermod
:
sudo usermod -L leahThis prepends an exclamation point to the password hash in /etc/shadow. It blocks password-based logins, but SSH key logins and some other authentication methods can still work.
To disable the account more completely, lock the password and expire the account:
sudo usermod -L -e 1 leahTo unlock the account and clear the expiry date:
sudo usermod -U -e "" leahTroubleshooting
deluser: The user does not exist
/usr/sbin/deluser: The user `leah' does not exist.Verify the username with id leah or getent passwd leah before deleting. The username is case-sensitive.
userdel: user is currently used by process
userdel: user leah is currently used by process 12345The user has active processes or sessions. List them before you stop anything:
pgrep -u leah -aAfter you confirm that the processes can be stopped, terminate them and remove the account:
sudo pkill -u leah
sudo deluser --remove-home leahThe --remove-home flag deletes the user’s home directory. Use sudo deluser leah instead if you need to keep or archive the files first.
Sudo privileges not active
After running usermod -aG sudo leah, the new group membership only applies to new login sessions. Either log out and back in, or start a new session with:
su - leahCannot remove primary group
/usr/sbin/deluser: The group `leah' is the primary group of another userA user still belongs to the group. Remove the user first, then the group with sudo delgroup leah.
FAQ
What is the difference between adduser and useradd on Debian?
Both commands create user accounts, but they work at different levels. useradd is a low-level utility that creates the account without asking any questions, which makes it a good fit for scripts. adduser is a friendlier Perl wrapper that walks you through setting the password and personal info, creates the home directory for you, and copies the skeleton files. For day-to-day use on Debian, you usually want adduser.
How do I delete a user but keep their home directory?
Run sudo deluser leah without the --remove-home flag. The account is removed from /etc/passwd and /etc/shadow, but the home directory and mail spool are left in place. This is useful when you want to archive the user’s files before removing them, or when another account will take over the same data.
Should I lock or delete an inactive user?
If there is a chance the person will return, or if you need to preserve their file ownership for auditing, lock password authentication with sudo usermod -L leah, or expire the account with sudo usermod -L -e 1 leah when you need a stronger block. The home directory and files stay intact. Delete with deluser --remove-home only when you are certain the user and their data are no longer needed.
Conclusion
When provisioning a new Debian server, the typical flow is adduser to create the account, then usermod -aG sudo to grant administrative rights. Lock dormant accounts instead of deleting them when you need an audit trail of past file ownership.
For multi-server setups, see our guide on generating SSH keys on Linux so new users can log in without passwords.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page