userdel Command

Purpose

Removes a user account.

Syntax

userdel [ -r | -f ] login

Description

The userdel command removes the user account identified by the login parameter. The command removes a user's attributes without removing the user's home directory by default. The user name must already exist. If the -r flag is specified, the userdel command also removes the user's home directory.

Only the root user or users with UserAdmin authorization can remove administrative users. Administrative users are those users with admin=true set in the /etc/security/user file.

Flags

Item Description
-r Removes the home directory of the user. Files located in other file systems need to be searched manually and deleted.
-f Forces the removal of the user account along with the home directory and the mail spool, even if the same home directory is accessed by another user or even if the mail spool is not owned by the specified user.
Note: This option might leave your system in an inconsistent state.

Exit Status

Item Description
0 The command completed successfully.
>0 An error occurred.

Security

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in AIX® Version 7.1 Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.

Examples

  1. To remove the user davis account and its attributes from the local system, enter:
    userdel davis

Location

/usr/sbin/userdel

Files

The userdel command has read and write permissions to the following files.

Item Description
/etc/passwd Contains the basic attributes of users.
/etc/security/user Contains the extended attributes of users.
/etc/security/user.roles Contains the administrative role attributes of users.
/etc/security/limits Defines resource quotas and limits for each user.
/etc/security/environ Contains the environment attributes of users.
/etc/security/audit/config Contains audit configuration information.
/etc/security/lastlog Contains the last login attributes of users.
/etc/group Contains the basic attributes of groups.
/etc/security/group Contains the extended attributes of groups.