Permissions, users and access

Command userdel

Delete user

Linux · Bash examples · commands run on the selected server

When to use userdel

Use userdel only for a known account that is no longer needed. Review running processes, scheduled work and owned files first; removing an account is not a complete audit of that identity's data.

Syntax

userdel [PARAMETERS] NAME

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

-r
Also remove home directory and mail spool.
Without -r
Delete the account, keeping the home directory.

Usage examples

Check identity before deleting

id demo-user

The account's identity is inspected before any removal.

Check user processes

pgrep -u demo-user -a

Processes belonging to that account are listed so active work can be identified.

Delete the selected test account

sudo userdel demo-user

The account entry is removed without requesting recursive deletion of its home directory.

Notes and limitations

  • Deleting an account may leave files with the same number UID. Check owners and backups.
  • The -r option deletes data; don't use it without checking your home directory separately.

Common questions and troubleshooting

Will this remove every file the user owned?

No. Files elsewhere can remain with the numeric owner ID. Inventory and reassign or archive data deliberately.

Why must numeric IDs be considered after deletion?

If an ID is later reused, old files can appear owned by the new account. Resolve retained ownership as part of account retirement.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man userdel.