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.

  1. Identify the exact username, not the person’s full display name. Similar usernames are easy to confuse.
  2. Make sure you are not deleting the administrative account you still need. Keep another verified administrator available.
  3. Check whether the account owns important files outside its home directory, such as project data, service files, or files on another mounted filesystem.
  4. Review active logins, processes, services, scheduled jobs, and remote sessions for the account. Stop or migrate them safely before removal.
  5. 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

MethodBest forAdministrator authenticationCan choose whether to keep filesKey limitation
Ubuntu User Accounts graphical toolDesktop users who prefer settings panelsUnlock the panel with administrator authenticationYes, through the confirmation dialogLocation and labels can vary between desktop versions
deluser commandDebian-family administration and scriptsRun as root or through sudoYes, by choosing the appropriate optionUse the exact login username
userdel command as a lower-level alternativeAdministrators who specifically need the lower-level utilityUsually root or sudoOptions and behavior differ by distributionPrefer 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.

  1. Open the desktop system settings.
  2. Open User Accounts.
  3. Choose Unlock or the equivalent control.
  4. Authenticate with an administrator password. Account controls may remain disabled until the panel is unlocked.
  5. Select the intended account from the account list.
  6. Use the remove or minus control.
  7. 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.
  8. 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 optionPurposeEffect on home directory
deluser usernameRemove the specified local user accountNormally leaves the home directory in place
deluser --remove-home usernameRemove the account and its home data and mail spoolRemoves 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 choiceLogin accountHome directoryMail spoolFiles outside home directory
Delete account while retaining filesRemovedNormally retainedNormally retained unless separately removedRetained and must be reviewed separately
Delete account and remove home dataRemovedRemoved when the operation succeedsRemoved with the account dataMay 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 username removes the account while normally retaining the home directory.
  • deluser --remove-home username requests 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.