- 1How to Add a New User in Linux
- 2Modify Existing User in Linux
- 3Delete a User in Linux — Step-by-Step for Beginners
- 4Create a User Group in Linux - Step-by-Step Tutorial
- 5Linux: Add User to Group
- 6How to Remove a User from a Group in Linux
- 7Delete a User Group in Linux - Beginner Friendly Tutorial
- 8Linux su Command Tutorial – Switch Users Easily
- 9Linux sudo Command - Execute as Another User
- 10Change a User's Password in Linux Using passwd
- 11Set Password Expiry in Linux using chage
- 12Lock a User Account in Linux
- 13How to Unlock a User Account in Linux
- 14Configure User Login Shell in Linux
- 15How to Configure User Environment Variables in Linux
- 16Edit .bashrc and .profile in Linux - User Startup Files Tutorial

- 1Linux Topics Index
- 2How to Create a File in Linux
- 3How to Rename a File in Linux
- 4How to Copy a File in Linux
- 5How to Move a File in Linux
- 6How to Delete a File in Linux
- 7How to Create a Directory in Linux
- 8How to Delete a Directory in Linux
- 9How to Copy Directories Recursively in Linux
- 10Delete Directories Recursively in Linux
- 11How to View Hidden Files in Linux
- 12How to Create a Hidden File in Linux
- 13How to Create a Hidden Directory in Linux
- 14How to Find Files in Linux Using find Command
- 15Find Files in Linux Using locate Command
- 16How to View File Contents Using cat in Linux
- 17How to View File Contents Using less in Linux
- 18View File Contents Using the more Command in Linux
- 19Compare Files Using diff Command in Linux
- 20Compare Files in Linux Using cmp Command
- 21Check File Type in Linux with file Command
- 22Create Symbolic Links with ln -s in Linux
- 23How to Archive Files Using tar Command in Linux
- 24Compress Files with gzip in Linux – Beginner Tutorial
- 25How to Compress Files Using bzip2 in Linux
- 26Compress Files in Linux Using zip Command
- 27Extract Compressed Files using tar in Linux
- 28Extract ZIP Files on Linux with unzip
- 29How to Extract .gz Files using gunzip in Linux

- 1How to Add a New User in Linux
- 2Modify Existing User in Linux
- 3Delete a User in Linux — Step-by-Step for Beginners
- 4Create a User Group in Linux - Step-by-Step Tutorial
- 5Linux: Add User to Group
- 6How to Remove a User from a Group in Linux
- 7Delete a User Group in Linux - Beginner Friendly Tutorial
- 8Linux su Command Tutorial – Switch Users Easily
- 9Linux sudo Command - Execute as Another User
- 10Change a User's Password in Linux Using passwd
- 11Set Password Expiry in Linux using chage
- 12Lock a User Account in Linux
- 13How to Unlock a User Account in Linux
- 14Configure User Login Shell in Linux
- 15How to Configure User Environment Variables in Linux
- 16Edit .bashrc and .profile in Linux - User Startup Files Tutorial
How to Delete an Existing User in Linux
Next Topic ⮕Create a User Group in Linux - Step-by-Step Tutorial
How to Delete an Existing User in Linux
Hey there, and welcome back to ProgramGuru.org! In this tutorial, we're going to learn how to delete a user from a Linux system. Don't worry if you're just starting out — we'll take it step-by-step and explain everything along the way.
Let’s say you created a user for testing or for someone who no longer needs access. You don’t want them to keep cluttering your system, right? So here’s how you can remove them cleanly and safely.
Step 1: Open the Terminal
You can open the terminal using Ctrl + Alt + T
, or search for "Terminal" in your application menu.
Step 2: Check Existing Users
Before deleting a user, you might want to check who exists on the system.
cut -d: -f1 /etc/passwd
root
daemon
bin
sys
john
testuser
Here, we see a list of user accounts. Let's say we want to delete testuser
.
Step 3: Delete the User
To delete a user, use the userdel
command. You’ll need superuser (admin) privileges, so either log in as root or use sudo
.
sudo userdel testuser
This removes the user from the system, but their files in the home directory still remain.
Step 4: Delete User and Home Directory (Optional)
If you want to remove the user and their home directory at the same time, use the -r
option:
sudo userdel -r testuser
This will delete:
- The user account
- The user's home directory (like
/home/testuser
) - Mail spool and other user-owned files in typical locations
Step 5: Confirm Deletion
You can check if the user was deleted successfully:
id testuser
id: ‘testuser’: no such user
If you see that message, it means the user is gone!
Wrap Up
And that’s it! You’ve just learned how to delete a user from your Linux system. 🎉
To quickly recap:
- Use
userdel
to remove a user - Add
-r
to also remove their home directory - Always check with
id username
to confirm
Thanks for watching! If you found this helpful, don’t forget to check out other beginner-friendly Linux tutorials at ProgramGuru.org.