VMware ESXi and vSphere Cluster Management
Delete Users in Ubuntu and Debian Linux
Learn how to delete a local Ubuntu or Debian user with User Accounts or deluser, while choosing whether to retain or remove the user’s files.
Deleting a local Linux user removes that account’s login identity from the system. It does not automatically mean that every file associated with the person will be deleted. Before proceeding, decide whether the user’s data must be retained for backup, auditing, transfer, or recovery.
What deleting a user account does
A user account is a local identity that can authenticate, own files, and run processes. Its username is the short account identifier used in commands such as deluser. The account also has a numeric UID, or user identifier, which Linux records as file ownership.
Removing the account prevents normal login with that identity and removes the account from the local account database. Account deletion and data deletion are separate decisions:
- The account identity and login credentials can be removed while the home directory remains.
- The home directory can be removed along with the account when its personal data is no longer needed.
- Files outside the home directory may remain even when the home directory is deleted.
- A local mail spool, which stores mail associated with the account, may be removed when account data is removed.
Prerequisites and safety checks
You need an account with sudo access or another form of administrative privilege. sudo lets an authorized user run a command with administrative permissions. The root account is the unrestricted superuser, but using an authorized administrator through sudo is usually preferable.
- Identify the exact username, not the person’s full display name. Similar usernames are easy to confuse.
- Make sure you are not deleting the administrative account you still need. Keep another verified administrator available.
- Check whether the account owns important files outside its home directory, such as project data, service files, or files on another mounted filesystem.
- Review active logins, processes, services, scheduled jobs, and remote sessions for the account. Stop or migrate them safely before removal.
- Back up or transfer required data before selecting a delete-files option.
When possible, record the account’s UID before deletion. For example, id username displays account and group information, including the UID. You can use that UID later to find files that no longer resolve to a username.
Ways to delete a user in Ubuntu and Debian
| Method | Best for | Administrator authentication | Can choose whether to keep files | Key limitation |
|---|---|---|---|---|
| Ubuntu User Accounts graphical tool | Desktop users who prefer settings panels | Unlock the panel with administrator authentication | Yes, through the confirmation dialog | Location and labels can vary between desktop versions |
deluser command | Debian-family administration and scripts | Run as root or through sudo | Yes, by choosing the appropriate option | Use the exact login username |
userdel command as a lower-level alternative | Administrators who specifically need the lower-level utility | Usually root or sudo | Options and behavior differ by distribution | Prefer the distribution-recommended tool and documentation |
Delete a user with Ubuntu User Accounts
Ubuntu’s User Accounts panel is the graphical tool for managing local user accounts. The exact appearance can differ between Ubuntu releases, but the workflow is generally the same.
- Open the desktop system settings.
- Open User Accounts.
- Choose Unlock or the equivalent control.
- Authenticate with an administrator password. Account controls may remain disabled until the panel is unlocked.
- Select the intended account from the account list.
- Use the remove or minus control.
- Read the confirmation dialog carefully. Choose to keep the user’s files if they are needed, or choose to delete the files only after confirming that data has been backed up or transferred.
- After the operation finishes, verify that the account no longer appears in the User Accounts list.
Keeping the files removes the login identity but leaves the home directory available for later archiving, reassignment, review, or deliberate removal. Deleting the files removes the standard home-directory data selected by the tool, but it does not guarantee that all files owned by the account elsewhere have been removed.
Delete a user with deluser
deluser is the recommended high-level account-removal command on Debian-family systems, including Debian and Ubuntu. Use the account name, not the person’s full display name.
Remove the account and retain its home directory
The basic form removes the local account while normally leaving the home directory in place:
sudo deluser username
Replace username with the exact login name. Run the command as root or through sudo, and confirm the target before pressing Enter.
Remove the account, home directory, and mail spool
When the user’s local personal data is no longer needed and has been backed up or transferred, use:
sudo deluser --remove-home username
This removes the local account and requests removal of its home directory and mail spool. Files owned by the user outside the normal home directory may still remain and require separate review.
| Command or option | Purpose | Effect on home directory |
|---|---|---|
deluser username | Remove the specified local user account | Normally leaves the home directory in place |
deluser --remove-home username | Remove the account and its home data and mail spool | Removes the user’s home directory when possible |
deluser and userdel
userdel is a lower-level account-management utility. deluser is a Debian/Ubuntu-friendly frontend that invokes lower-level account-removal behavior while providing Debian-family conventions and options.
Options, defaults, and related cleanup behavior can vary by distribution. On Debian-family systems, follow the documentation and administrative conventions for deluser. If working on another distribution, use the account-removal tool recommended by that distribution rather than assuming that every option has the same meaning.
Choosing what happens to user data
| Removal choice | Login account | Home directory | Mail spool | Files outside home directory |
|---|---|---|---|---|
| Delete account while retaining files | Removed | Normally retained | Normally retained unless separately removed | Retained and must be reviewed separately |
| Delete account and remove home data | Removed | Removed when the operation succeeds | Removed with the account data | May remain under the former numeric UID |
Retaining a home directory is useful when another administrator needs to review or archive it, when ownership will later be reassigned, or when recovery may be necessary. After review, the directory can be archived, reassigned deliberately, or removed.
Removing a home directory does not necessarily remove every file owned by that user elsewhere. Linux stores ownership as a numeric UID. After the account name is gone, such files can appear as owned by an unknown numeric ID or may simply show the UID in administrative tools. These are called orphaned files.
Post-deletion verification and cleanup
Check that the account no longer resolves
Use the local account database lookup:
getent passwd username
No output after removal generally indicates that the account no longer resolves through the account database. You can also test name resolution with:
id username
After successful deletion, this should report that the user does not exist.
Check the home directory
Confirm whether the home directory remains or has been removed according to your selected option. If it remains, decide whether to archive it, transfer its contents, reassign ownership, or remove it deliberately after review.
Find files owned by the former UID
If you recorded the former UID, search a deliberate filesystem path for remaining ownership:
find /path/to/search -uid FORMER_UID -print
Replace /path/to/search with a selected location and FORMER_UID with the recorded numeric UID. Avoid blindly searching every mounted filesystem, because that can be slow and may include unrelated storage. Review each result before archiving, changing ownership, or deleting it.
Review related access
- Scheduled jobs and cron entries associated with the account.
- Services or application processes that run under the account.
- Shared group memberships and access granted through those groups.
- SSH keys and remote-login configuration.
- Application-specific accounts, permissions, tokens, and stored credentials.
- Files, backups, and data stored outside the user’s home directory.
Troubleshooting
User Accounts controls are disabled
The panel may not be unlocked, the current user may lack administrator privileges, or the desktop environment may place account management in a different settings location. Unlock the panel and authenticate with an administrator password. If you cannot do that, use an authorized administrator account or run deluser from a terminal with appropriate privileges.
deluser says that the user does not exist
Check for a misspelled username, an account that was already removed, or use of a person’s full display name instead of the login name. Use getent passwd username or inspect the User Accounts panel to identify the exact account name.
The account is gone but files remain
The command may have been run without --remove-home, the files may be outside the home directory, or the files may be on another mounted filesystem. Decide whether the data should be archived, reassigned, or removed, then search selected paths by the former UID.
Deletion fails because the account is in use
The user may still be logged in locally or remotely, or a process, service, job, or session may still run under the account. Review active sessions and processes, end them safely, and retry. Do not terminate processes without understanding their service impact.
The wrong account was targeted
Similar usernames and insufficient verification are common causes. Before confirming removal, verify the username, UID, home directory, and data-retention choice. If data was deleted unintentionally, recovery depends on available backups or other recovery procedures.
Exam-relevant notes
deluser usernameremoves the account while normally retaining the home directory.deluser --remove-home usernamerequests removal of the account, home directory, and mail spool.- Deleting an account does not automatically remove every file owned by its former UID.
- Use the username, not the user’s full display name.
- Record the UID before deletion when you may need to find orphaned files afterward.
- Administrative access and careful verification are required for safe account removal.
For related account-management procedures, see Delete Users in Ubuntu and Debian Linux.