How to Remove a User on Ubuntu (the Friendly, Beginner-Safe Way with deluser)

So you need to remove a user account on Ubuntu, and honestly? You’re a little nervous about it. That’s completely normal, and I want you to know you’re in exactly the right place. Deleting things on a server can feel scary the first time, like you might press one wrong key and break everything. Take a breath. We’re going to walk through this together, slowly and safely, and by the end you’ll feel totally fine doing it.

Here’s the good news right up front: Ubuntu gives us a really friendly command called `deluser`. Think of it as the polite, helpful version of removing a user. It handles a lot of the fiddly details for you and gives you clear, plain-English options. We’ll use that the whole way through. No scary surprises, I promise.

Key Takeaways
• On Ubuntu, use the friendly `deluser` command — it’s a gentler, safer wrapper than the lower-level `userdel`.
• `sudo deluser username` removes the account but keeps their home folder (their files stay put).
• `sudo deluser –remove-home username` removes the account and deletes their home folder.
• `sudo deluser –remove-all-files username` removes everything they own anywhere on the system — use this one carefully.
• You can’t delete a user who’s currently logged in, so log them out first.
Always back up the home folder before deleting if it might contain anything you’d want later. This makes the whole thing reversible-ish.

What does “removing a user” on Ubuntu actually mean?

Let’s start with the simplest possible picture, because understanding what’s happening makes everything feel less mysterious.

On Ubuntu (and any Linux system), a user is just an account — a name the system recognizes, with its own password, its own permissions, and usually its own home folder where their personal files live (something like `/home/jordan`). When we “remove a user,” we’re telling Ubuntu: *this account doesn’t need to exist anymore.*

Now here’s the important part, and it’s the question everyone worries about: what happens to their files? That depends entirely on which option you choose. You’re in control. By default, Ubuntu is cautious — it removes the account but leaves the home folder sitting safely on disk. You have to *specifically ask* it to delete the files. I love that, because it means you can’t accidentally nuke someone’s data just by removing their login. Ubuntu has your back here.

Why use deluser instead of userdel?

You might’ve seen tutorials use a command called `userdel`. It works, but I’d gently steer you toward `deluser` instead, especially while you’re learning. Here’s why.

`userdel` is the low-level tool. It does the bare mechanical job of deleting a user, and it expects *you* to remember all the little cleanup details. `deluser`, on the other hand, is Ubuntu’s friendly wrapper around that machinery. It’s written to be more careful, more readable, and more forgiving. It tidies up things like group memberships for you and gives you clear, human-friendly options like `–remove-home` and `–remove-all-files` that actually say what they do.

Here’s the insight I wish someone had told *me* early on: on Ubuntu, reach for the friendly `deluser`, not the lower-level `userdel`. They both delete users, but `deluser` is Ubuntu’s nicer, safer wrapper — it handles the fiddly details more gracefully and gives you clearer, self-explaining options (`–remove-home`, `–remove-all-files`) so you always know exactly what you’re about to do. Save `userdel` for the rare moment when you specifically need its raw, low-level behavior or you’re scripting on a system without `deluser` available. And whichever you use, always back up the home folder first, just in case — that one habit turns “oh no” into “no problem.” If you want the deeper technical breakdown of `userdel` and what’s happening under the hood, my colleague covers it here.

How do you remove a user on Ubuntu, step by step?

Okay, let’s actually do this. I’ll go nice and slow.

Step 1: Make sure the user isn’t logged in

Ubuntu won’t let you delete a user who’s currently logged in — and that’s a *feature*, not an annoyance. It stops you from yanking the rug out from under an active session. So first, let’s check who’s around:

“`bash who “`

That lists everyone currently logged in. If you see the username you want to delete, you’ll need to log them out (or wait for them to finish). You can ask a logged-in process to stop, but the simplest path is usually just making sure they’ve signed off before you continue.

Step 2: Remove the user (and keep their files)

This is the gentlest, safest version. It removes the account but leaves the home folder untouched:

“`bash sudo deluser jordan “`

That’s it. Replace `jordan` with the real username. The `sudo` part just means “I have permission to do admin stuff” — Ubuntu will ask for your password. After this runs, the account `jordan` is gone, but everything in `/home/jordan` is still sitting safely on the disk. If you change your mind later about the files, they’re right there.

Step 3 (optional): Remove the user AND their home folder

If you’re sure you don’t need their personal files, you can clean those up in the same breath:

“`bash sudo deluser –remove-home jordan “`

The `–remove-home` flag tells Ubuntu to also delete `/home/jordan` and everything inside it. Only do this once you’re confident you won’t need those files — or, even better, after you’ve backed them up (we’ll cover that in just a second).

Step 4 (rare, careful): Remove everything they own

There’s one more option, and I want you to treat it with respect:

“`bash sudo deluser –remove-all-files jordan “`

This removes the account *and* hunts down every file anywhere on the system that belongs to that user and deletes it — not just their home folder. It’s thorough, which also makes it the one to be most careful with. On a busy server, a user might own files in unexpected places, so only use `–remove-all-files` when you genuinely want a complete sweep and you’ve backed up anything important first.

What’s the difference between all these deluser options?

Let’s put them side by side so it’s crystal clear. Here’s your friendly cheat sheet:

Command What it does When to use it
`sudo deluser jordan` Removes the account, keeps the home folder The safe default — you want to keep their files
`sudo deluser –remove-home jordan` Removes the account and deletes their home folder You’re done with their files (back up first!)
`sudo deluser –remove-all-files jordan` Removes the account and all files they own anywhere A full cleanup — use carefully, back up first
`sudo deluser jordan developers` Removes `jordan` from the group `developers` only You just want to adjust permissions, not delete the user

Notice that last row — it’s a lovely little bonus.

How do you remove a user from a group (without deleting them)?

Sometimes you don’t want to delete a person at all. You just want to take away one of their permissions — say, remove them from the `sudo` group so they can’t run admin commands anymore, or pull them out of a project group. `deluser` does that too, and it’s beautifully simple. You just name the user *and* the group:

“`bash sudo deluser jordan developers “`

That removes `jordan` from the `developers` group, and nothing else. Their account stays, their files stay, their other groups stay. Only that one membership is gone. This is super handy for day-to-day permission tidying, and it’s a great example of why `deluser` is so friendly — the same command politely does very different jobs depending on whether you give it a group name.

If you’d like a broader, distro-agnostic walkthrough of managing and removing users in general, my colleague’s overview is a great companion read.

How do you do this safely? (The gentle warnings)

This is the part I care about most, because doing it *safely* is what’ll make you feel confident. None of these are scary — they’re just good habits.

1. Log them out first. As we covered, Ubuntu won’t delete a logged-in user. Run `who` and make sure they’re not active.

2. Back up the home folder before deleting. This is the big one. If there’s *any* chance their home folder contains something you might want later — files, configs, anything — copy it somewhere safe first. It takes ten seconds and it’s your safety net:

“`bash sudo tar -czf /root/backup-jordan.tar.gz /home/jordan “`

That bundles up their entire home folder into a single compressed file (`backup-jordan.tar.gz`) stored safely in `/root`. Now even if you run `–remove-home`, you can always unpack that backup and get the files back. This is what I mean when I say removal is reversible-ish — it’s not magic undo, but if you backed up first, you’ve lost nothing.

3. Double-check the username. Before you hit Enter, read the command out loud. Make sure `jordan` is really the account you mean to remove and not a typo for someone else. A two-second glance saves a lot of “oh no.”

4. Start with the safe default. When in doubt, use plain `sudo deluser jordan` (which keeps the home folder). You can always delete the files later once you’re sure. There’s no rush.


Want a server where managing Ubuntu users is easy?

Practicing user management — adding people, removing them, setting permissions — is so much more comfortable when you’ve got full root access and someone to ask if you’re unsure. That’s exactly what we built DarazHost to give you.

Our VPS and dedicated server plans come with complete root access on Ubuntu, so you can run `sudo deluser`, manage groups, and set permissions with total control — it’s *your* server, your rules. And because not everyone wants to figure this out alone, we back it all with genuinely 24/7 support from people who are happy to walk a beginner through it. Nervous about removing the wrong user? Ask us first. We’d rather answer the question than fix the mistake. Reliable hosting, beginner-friendly help, and the freedom to learn at your own pace — that’s the whole idea.


Frequently asked questions

What’s the difference between deluser and userdel on Ubuntu? They both remove users, but `deluser` is the friendlier, higher-level option Ubuntu recommends for everyday use — it handles cleanup details gracefully and offers clear flags like `–remove-home`. `userdel` is the lower-level tool that does the raw deletion and leaves more of the cleanup to you. For beginners, stick with `deluser`.

Does removing a user delete their files automatically? No, and that’s a good thing! By default, `sudo deluser username` keeps the home folder. The files are only deleted if you specifically add `–remove-home` (deletes their home folder) or `–remove-all-files` (deletes everything they own). Ubuntu plays it safe unless you tell it otherwise.

Why does Ubuntu say it can’t remove the user? The most common reason is that the user is currently logged in. Ubuntu won’t delete an active account. Run `who` to check, make sure they’re logged out, then try again. The other common reason is forgetting `sudo` — you need admin rights to remove a user.

Can I undo deleting a user? Not directly — there’s no “undo” button. But if you backed up the home folder first (with `tar`, like we showed above), you can restore their files anytime, which covers the part most people actually care about. Recreating the account itself is just a matter of adding the user again. This is exactly why the backup habit matters.

How do I just remove someone’s admin rights instead of deleting them? Remove them from the `sudo` group rather than deleting the account: `sudo deluser username sudo`. Their account and files stay intact — they simply lose the ability to run admin commands.

About the Author

Leave a Reply