userdel command in linux allows you to remove a user in linux. using -r flag with this userdel command to delete the user from the home directory.
userdel command | remove user in linux | flags | Examples
![]() |
Remove user from linux |
Hello, guys welcome to the next session on Linux command line tutorial.
In the last session, I show you how to create users in Linux using the "useradd" command.
Today I'm going to show you how you can remove users using "userdel" command.
Remove a user
![]() |
userdel command |
$sudo userdel userName
So in order to remove a user, we use a command called "userdel".
You need to give root permission before remove "users". So you must use "sudo" before this command.
So just write "sudo userdel userName" and press ENTER. It asks the root user's password. Enter the password and press ENTER KEY
Now you will observe even if you delete the user the "home directory" for this user is not deleted.
This command going to delete the username, password and other data for the user.
But it's not going to delete the home directory for the user.
use [-r] flag to remove a user from the home directory
![]() |
delete user from home directory |
You just need to use "sudo userdel -r userName".
- "-r" flag in order to remove the home directory.
So if you want to delete the "user" and also the "home directory" of the user. Then use "-r" flag with "userdel" command.
Otherwise use "userdel" with the "userName".
Conclusion
So in this way you can "remove user" using Linux command. I hope you've enjoyed this tutorial please rate comment and bye.
HAVE A NICE DAY💖
Related,