--- title: userdel — Remove a user account date: 2026-10-20 time: 12:00 model: admin category: programs author_type: human summary: Removes a user account and, with -r, its home directory and mail spool. tags: program, User and Security Management, userdel --- Removes a user account and, with -r, its home directory and mail spool. ## Basic Information | Command Name | userdel | | --- | --- | | One-line Introduction | Removes a user account and, with -r, its home directory and mail spool. | | Provided by | shadow-utils (passwd on some distributions) | | Official Documentation | https://man7.org/linux/man-pages/man8/userdel.8.html | | Supported Operating Systems | Linux | | Installation Status | Installed by default | | Category | Linux security and accounts (tags: Accounts, permissions and audit (tags: userdel, account, delete, user)) | ## What is this command? userdel removes account records from /etc/passwd, /etc/shadow and /etc/group. By default the home directory and mail spool remain, so use -r when the data should go too. Files created by the account keep their numeric owner UID. If that UID is later reused, the old files become accessible to the new user, so reassign or remove them before deletion. ## What problems does it solve? - Removing accounts of departed staff or temporary test users - Deleting a mistaken account together with its home directory - Reassigning owned files before removal - Reducing unnecessary login accounts for audit ## Key features ### Removing account entries Deletes the entries from passwd, shadow and group. - **When to use**: Cleaning up accounts that no longer need access - **What you get**: The name and UID disappear from the system. - **Limitations**: A user who is logged in cannot be removed. ### Removing the home directory The -r flag also deletes the home directory and mail spool. - **When to use**: When personal data must not remain - **What you get**: Space is reclaimed and leftovers are reduced. - **Limitations**: It is irreversible, so back up first. ### Pre-checks Check owned files and running processes first. - **When to use**: Understanding impact before removing a service account - **What you get**: Prevents permission issues and outages. - **Limitations**: Skipping checks leaves orphan files and broken services. ## Installation and usage ### Check whether it is installed ``` userdel --help ``` sudo apt install passwd # Debian/Ubuntu sudo dnf install shadow-utils # Fedora ## Real-world examples ### Remove the account only Remove the record while keeping the home directory. ``` sudo userdel olduser ``` ### Remove home as well Delete the home directory and mail spool together. ``` sudo userdel -r olduser ``` ### Check owned files first Find remaining files and decide whether to migrate them. ``` sudo find / -uid 1002 -ls 2>/dev/null | head ``` --- Source (HTML): https://games.aidebatehub.com/programs/linux/security/userdel.html This file is an auto-generated Markdown twin of the DevHub document.