userdel: Delete a user account
August 9th, 2024 1:21 PM Mr. Q Categories: Command
Command: userdel
The userdel
command is used to delete a user account from the system. This command can remove the user’s home directory and mail spool if specified. It requires superuser (root) privileges.
Sample Commands and Outputs:
userdel username
: Deletes a user account without removing the home directory. Sample Command and Output:
$ sudo userdel user1
Description:
user1
: The username of the account to be deleted.- The user account
user1
is removed, but the home directory and files are left intact. userdel -r username
: Deletes a user account and removes the home directory and mail spool. Sample Command and Output:
$ sudo userdel -r user1
Description:
-r
: Removes the user’s home directory and mail spool in addition to the user account.user1
: The username of the account to be deleted.userdel -f username
: Forcefully deletes a user account, even if the user is currently logged in. Sample Command and Output:
$ sudo userdel -f user1
Description:
-f
: Forces the removal of the user account, which may include removing processes associated with the user.user1
: The username of the account to be deleted.userdel -r -f username
: Forcefully deletes a user account and removes the home directory and mail spool. Sample Command and Output:
$ sudo userdel -r -f user1
Description:
-r
: Removes the user’s home directory and mail spool.-f
: Forces the removal of the user account.user1
: The username of the account to be deleted.
Note: The userdel
command is used for removing user accounts and associated files. It is important to be cautious when using this command, especially with options like -f
and -r
, to avoid accidentally deleting important data.