to list all users :

cut -d: -f1 /etc/passwd

To remove user :

sudo userdel username

To remove home directory :

sudo rm -r /home/username

To add a home directory to an existing user :

create a home directory

chown this directory for the user

sudo usermod -d /home/directory user
Answer from nux on askubuntu.com
🌐
TecMint
tecmint.com › home › linux commands › how to delete user accounts and their home directories in linux
How to Delete User Accounts & Home Directories in Linux
February 13, 2024 - Let’s now move further to see how to delete or remove user accounts in Linux using deluser (For Debian and its derivatives) and userdel (For RedHat-based systems) commands. sudo deluser --remove-home username sudo userdel -r username · The ...
People also ask

Does `userdel` delete the home directory?
Not by default. Use `userdel -r` to remove the home directory and mail spool along with the account.
🌐
linuxize.com
linuxize.com › home › linux commands › how to remove a user in linux
How to Remove a User in Linux | Linuxize
Does deleting a user remove their cron jobs?
No. Run `sudo crontab -r -u username` before deleting the user to remove their scheduled cron jobs.
🌐
linuxize.com
linuxize.com › home › linux commands › how to remove a user in linux
How to Remove a User in Linux | Linuxize
How do I undo a user deletion?
You cannot undo `userdel`. If you deleted the home directory with `-r`, the data is gone unless you have a backup. You would need to recreate the user and restore their files.
🌐
linuxize.com
linuxize.com › home › linux commands › how to remove a user in linux
How to Remove a User in Linux | Linuxize
🌐
Linuxize
linuxize.com › home › linux commands › how to remove a user in linux
How to Remove a User in Linux | Linuxize
May 6, 2026 - To remove a user account and keep ... files. To remove the user account along with the home directory and mail spool, use the -r (--remove) option:...
🌐
StrongDM
strongdm.com › blog › security
How To Delete/Remove Users in Linux (userdel, deluser & Manually)
February 27, 2025 - First, run sudo chattr-i /home/<username> to allow for modifications and deletion on the home directory. chattr -i removes the immutable flag, allowing directory deletion. Next, run sudo rm -rf /home/<username> to forcefully delete it.
🌐
LinuxOPsys
linuxopsys.com › delete-user-home-directory-on-ubuntu
How to Delete a User with Home Directory on Ubuntu
January 27, 2023 - The recommended command to delete a user on Ubuntu is deluser. By default, the deluser <username> deletes the user but keeps its home directory. To delete a user including the home directory use deluser with --remove-home option.
Find elsewhere
🌐
LinuxSimply
linuxsimply.com › home › how to remove a user and home directory in linux [2 methods]
How to Remove a User and Home Directory in Linux [2 Methods]
April 25, 2024 - Read More: 2 Cases of Recursive Remove of Directory in Linux · Another command that you can use to remove a user account, is the deluser command. With the command option –remove-home you can delete a user and its home directory.
🌐
Ucartz Online Pvt Ltd
ucartz.com › clients › knowledgebase › 2046 › How-to-Delete-User-Accounts-with-Home-Directory-in-Linux.html
How to Delete User Accounts with Home Directory in Linux? - Ucartz
# adduser rootadminz # passwd rootadminz # adduser adminlinux # passwd adminlinux · From the screenshot above, I have used the adduser command to create user accounts on Linux. You can also use useradd command, both are same and does the same job. 2. Let’s now move further to see how to ...
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_enterprise_linux › 6 › html › deployment_guide › cl-tools-userdel
3.4.5. Deleting Users | Deployment Guide | Red Hat Enterprise Linux | 6 | Red Hat Documentation
Combining userdel with the -r option removes files in the user's home directory along with the home directory itself and the user's mail spool. Files located in other file systems have to be searched for and deleted manually.
🌐
nixCraft
cyberciti.biz › nixcraft › howto › linux › how to delete/remove users in linux using userdel command
Linux Delete / Remove User Account Using userdel command - nixCraft
August 9, 2023 - Let us remove the user named vivek or account named vivek from the local Linux system / server / workstation, enter: # userdel vivek Next, delete the user’s home directory and mail spool pass the -r option to userdel for a user named ashish, enter: # userdel -r ashish · Explains how to delete user account with home directory in Linux The above command will remove all files along with the home directory itself and the user’s mail spool.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-delete-user-accounts-with-home-directory-in-linux
How to Delete User Accounts with Home Directory in Linux?
March 26, 2025 - By using the userdel -r command (or deluser --remove-home on Debian/Ubuntu), you can securely remove user accounts and their associated files, maintaining system security and optimizing resource utilization.
🌐
YouTube
youtube.com › watch
How to Remove a User and Home Directory in Linux [2 Methods] | LinuxSimply - YouTube
In the Linux operating system, having multiple users is a common scenario. However, at times, it may be necessary to remove a user account and its associated...
Published   June 6, 2023
🌐
Position Is Everything
positioniseverything.net › home › how to delete user with home directory in linux: a comprehensive guide
How to Delete User with Home Directory in Linux: A Comprehensive Guide - Position Is Everything
December 29, 2025 - Removing a user and their home directory in Linux can be done efficiently with commands like userdel -r <username> or deluser --remove-home <username>. Deleting user accounts is a task every Linux system administrator deals with frequently.
🌐
IT SMART TRICKS
itsmarttricks.com › home › how to delete user accounts with home directory in linux
How To Delete User Accounts With Home Directory In Linux
February 26, 2021 - In this instructional tutorial, I will make yours through steps you can use to delete a user’s account along with his/her home directory on a Linux system.
🌐
Fedingo
fedingo.com › home
How to Delete User Accounts with Home Directory in Linux
September 5, 2022 - December 14, 2022June 5, 2024 Sreeram Sreenivasan Leave a comment CentOS/RHEL, Linux, Python, Ubuntu
🌐
Arch Linux Forums
bbs.archlinux.org › viewtopic.php
How do I remove my user and the homefolder? / Newbie Corner / Arch Linux Forums
substituting your username for reploid if it's not that. If you leave off the -r, it won't delete your home directory (however, you won't be able to use it if you don't recreate the account with the same UID).
🌐
DropVPS
dropvps.com › home › blog › how to delete user in linux with home directory
How To Delete user in linux with home directory - DropVPS
November 8, 2024 - Check for Active Processes: Stop any active processes associated with the user before running userdel to avoid errors. These steps and options help ensure safe and effective use of the userdel command for user management in Linux.
🌐
GeeksforGeeks
geeksforgeeks.org › userdel-command-in-linux-with-examples
How to Delete User in Linux | userdel Command - GeeksforGeeks
September 19, 2024 - ... 'userdel -r': Whenever we are deleting a user using this option then the files in the user's home directory will be removed along with the home directory itself and the user's mail spool.