{
    "content": [
        {
            "type": "text",
            "text": "# USERDEL (info)\n\n## NAME\n\nuserdel - delete a user account and related files\n\n## SYNOPSIS\n\nuserdel [options] LOGIN\n\n## DESCRIPTION\n\nuserdel is a low level utility for removing users. On Debian,\nadministrators should usually use deluser(8) instead.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (4 subsections)\n- **CONFIGURATION**\n- **FILES**\n- **EXIT VALUES**\n- **CAVEATS**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "USERDEL",
        "section": "",
        "mode": "info",
        "summary": "userdel - delete a user account and related files",
        "synopsis": "userdel [options] LOGIN",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [
            {
                "flag": "-f",
                "long": "--force",
                "arg": null,
                "description": "This option forces the removal of the user account, even if the user is still logged in. It also forces userdel to remove the user's home directory and mail spool, even if another user uses the same home directory or if the mail spool is not owned by the specified user. If USERGROUPSENAB is defined to yes in /etc/login.defs and if a group exists with the same name as the deleted user, then this group will be removed, even if it is still the primary group of another user. Note: This option is dangerous and may leave your system in an inconsistent state."
            },
            {
                "flag": "-h",
                "long": "--help",
                "arg": null,
                "description": "Display help message and exit."
            },
            {
                "flag": "-r",
                "long": "--remove",
                "arg": null,
                "description": "Files in the user's home directory will be removed along with the home directory itself and the user's mail spool. Files located in other file systems will have to be searched for and deleted manually. The mail spool is defined by the MAILDIR variable in the login.defs file. -R, --root CHROOTDIR Apply changes in the CHROOTDIR directory and use the configuration files from the CHROOTDIR directory. -P, --prefix PREFIXDIR Apply changes in the PREFIXDIR directory and use the configuration files from the PREFIXDIR directory. This option does not chroot and is intended for preparing a cross-compilation target. Some limitations: NIS and LDAP users/groups are not verified. PAM authentication is using the host files. No SELINUX support."
            },
            {
                "flag": "-Z",
                "long": "--selinux-user",
                "arg": null,
                "description": "Remove any SELinux user mapping for the user's login."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "chfn",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/chfn/1/json"
            },
            {
                "name": "chsh",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/chsh/1/json"
            },
            {
                "name": "passwd",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/passwd/1/json"
            },
            {
                "name": "login.defs",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/login.defs/5/json"
            },
            {
                "name": "gpasswd",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/gpasswd/8/json"
            },
            {
                "name": "groupadd",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/groupadd/8/json"
            },
            {
                "name": "groupdel",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/groupdel/8/json"
            },
            {
                "name": "groupmod",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/groupmod/8/json"
            },
            {
                "name": "subgid",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/subgid/5/json"
            },
            {
                "name": "subuid",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/subuid/5/json"
            },
            {
                "name": "useradd",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/useradd/8/json"
            },
            {
                "name": "usermod",
                "section": "8",
                "url": "https://www.chedong.com/phpMan.php/man/usermod/8/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 2,
                "subsections": [
                    {
                        "name": "-f, --force",
                        "lines": 12,
                        "flag": "-f",
                        "long": "--force"
                    },
                    {
                        "name": "-h, --help",
                        "lines": 2,
                        "flag": "-h",
                        "long": "--help"
                    },
                    {
                        "name": "-r, --remove",
                        "lines": 19,
                        "flag": "-r",
                        "long": "--remove"
                    },
                    {
                        "name": "-Z, --selinux-user",
                        "lines": 2,
                        "flag": "-Z",
                        "long": "--selinux-user"
                    }
                ]
            },
            {
                "name": "CONFIGURATION",
                "lines": 71,
                "subsections": []
            },
            {
                "name": "FILES",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "EXIT VALUES",
                "lines": 23,
                "subsections": []
            },
            {
                "name": "CAVEATS",
                "lines": 19,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "userdel - delete a user account and related files\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "userdel [options] LOGIN\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "userdel is a low level utility for removing users. On Debian,\nadministrators should usually use deluser(8) instead.\n\nThe userdel command modifies the system account files, deleting all\nentries that refer to the user name LOGIN. The named user must exist.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "The options which apply to the userdel command are:\n",
                "subsections": [
                    {
                        "name": "-f, --force",
                        "content": "This option forces the removal of the user account, even if the\nuser is still logged in. It also forces userdel to remove the\nuser's home directory and mail spool, even if another user uses the\nsame home directory or if the mail spool is not owned by the\nspecified user. If USERGROUPSENAB is defined to yes in\n/etc/login.defs and if a group exists with the same name as the\ndeleted user, then this group will be removed, even if it is still\nthe primary group of another user.\n\nNote: This option is dangerous and may leave your system in an\ninconsistent state.\n",
                        "flag": "-f",
                        "long": "--force"
                    },
                    {
                        "name": "-h, --help",
                        "content": "Display help message and exit.\n",
                        "flag": "-h",
                        "long": "--help"
                    },
                    {
                        "name": "-r, --remove",
                        "content": "Files in the user's home directory will be removed along with the\nhome directory itself and the user's mail spool. Files located in\nother file systems will have to be searched for and deleted\nmanually.\n\nThe mail spool is defined by the MAILDIR variable in the\nlogin.defs file.\n\n-R, --root CHROOTDIR\nApply changes in the CHROOTDIR directory and use the configuration\nfiles from the CHROOTDIR directory.\n\n-P, --prefix PREFIXDIR\nApply changes in the PREFIXDIR directory and use the configuration\nfiles from the PREFIXDIR directory. This option does not chroot\nand is intended for preparing a cross-compilation target. Some\nlimitations: NIS and LDAP users/groups are not verified. PAM\nauthentication is using the host files. No SELINUX support.\n",
                        "flag": "-r",
                        "long": "--remove"
                    },
                    {
                        "name": "-Z, --selinux-user",
                        "content": "Remove any SELinux user mapping for the user's login.\n",
                        "flag": "-Z",
                        "long": "--selinux-user"
                    }
                ]
            },
            "CONFIGURATION": {
                "content": "The following configuration variables in /etc/login.defs change the\nbehavior of this tool:\n\nMAILDIR (string)\nThe mail spool directory. This is needed to manipulate the mailbox\nwhen its corresponding user account is modified or deleted. If not\nspecified, a compile-time default is used.\n\nMAILFILE (string)\nDefines the location of the users mail spool files relatively to\ntheir home directory.\n\nThe MAILDIR and MAILFILE variables are used by useradd, usermod, and\nuserdel to create, move, or delete the user's mail spool.\n\nMAXMEMBERSPERGROUP (number)\nMaximum members per group entry. When the maximum is reached, a new\ngroup entry (line) is started in /etc/group (with the same name,\nsame password, and same GID).\n\nThe default value is 0, meaning that there are no limits in the\nnumber of members in a group.\n\nThis feature (split group) permits to limit the length of lines in\nthe group file. This is useful to make sure that lines for NIS\ngroups are not larger than 1024 characters.\n\nIf you need to enforce such limit, you can use 25.\n\nNote: split groups may not be supported by all tools (even in the\nShadow toolsuite). You should not use this variable unless you\nreally need it.\n\nUSERDELCMD (string)\nIf defined, this command is run when removing a user. It should\nremove any at/cron/print jobs etc. owned by the user to be removed\n(passed as the first argument).\n\nThe return code of the script is not taken into account.\n\nHere is an example script, which removes the user's cron, at and\nprint jobs:\n\n#! /bin/sh\n\n# Check for the required argument.\nif [ $# != 1 ]; then\necho \"Usage: $0 username\"\nexit 1\nfi\n\n# Remove cron jobs.\ncrontab -r -u $1\n\n# Remove at jobs.\n# Note that it will remove any jobs owned by the same UID,\n# even if it was shared by a different username.\nATSPOOLDIR=/var/spool/cron/atjobs\nfind $ATSPOOLDIR -name \"[^.]*\" -type f -user $1 -delete \\;\n\n# Remove print jobs.\nlprm $1\n\n# All done.\nexit 0\n\nUSERGROUPSENAB (boolean)\nIf set to yes, userdel will remove the user's group if it contains\nno more members, and useradd will create by default a group with\nthe name of the user.\n",
                "subsections": []
            },
            "FILES": {
                "content": "/etc/group\nGroup account information.\n\n/etc/login.defs\nShadow password suite configuration.\n\n/etc/passwd\nUser account information.\n\n/etc/shadow\nSecure user account information.\n\n/etc/subgid\nPer user subordinate group IDs.\n\n/etc/subuid\nPer user subordinate user IDs.\n",
                "subsections": []
            },
            "EXIT VALUES": {
                "content": "The userdel command exits with the following values:\n\n0\nsuccess\n\n1\ncan't update password file\n\n2\ninvalid command syntax\n\n6\nspecified user doesn't exist\n\n8\nuser currently logged in\n\n10\ncan't update group file\n\n12\ncan't remove home directory\n",
                "subsections": []
            },
            "CAVEATS": {
                "content": "userdel will not allow you to remove an account if there are running\nprocesses which belong to this account. In that case, you may have to\nkill those processes or lock the user's password or account and remove\nthe account later. The -f option can force the deletion of this\naccount.\n\nYou should manually check all file systems to ensure that no files\nremain owned by this user.\n\nYou may not remove any NIS attributes on a NIS client. This must be\nperformed on the NIS server.\n\nIf USERGROUPSENAB is defined to yes in /etc/login.defs, userdel will\ndelete the group with the same name as the user. To avoid\ninconsistencies in the passwd and group databases, userdel will check\nthat this group is not used as a primary group for another user, and\nwill just warn without deleting the group otherwise. The -f option can\nforce the deletion of this group.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "chfn(1), chsh(1), passwd(1), login.defs(5), gpasswd(8), groupadd(8),\ngroupdel(8), groupmod(8), subgid(5), subuid(5), useradd(8), usermod(8).\n\nshadow-utils 4.8.1                02/06/2024                        USERDEL(8)",
                "subsections": []
            }
        }
    }
}