userdel Command
Purpose
Removes a user account.
Syntax
userdel [ -r] 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.
If the AIX_USERDEL_RECURSIVE_DEL environment variable is set, the userdel command recursively deletes the directories and files that belong to the removed user. If another user uses the same home directory, the files and directories of the user is preserved. If the directory of the deleted user contains content owned by a different user, the directory ownership of the user is changed to the user nobody with a permission of 777 and a sticky bit set. This operation is performed for the continued access of the directory and its content for the affected users by using the same home space. It is very important to change the permission and ownership of the affected directories to a new user immediately after running the userdel command. The system administrator can change the permission and ownership setting of the affected directories to a new user to prevent illegal access.
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 must be searched manually and deleted. Removing the home directory, which is shared by other users, might leave the system in an inconsistent state. |
Exit Status
Item | Description |
---|---|
0 | The command completed successfully. |
>0 | An error occurred. |
Security
Examples
- 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. |