To delete a user via the command line, open a terminal and execute the following command. Be sure to replace ‘username’ with the actual name of the user you wish to delete.

$ sudo userdel username

To remove the user’s home directory at the same time, add the -r option.

$ sudo userdel -r username

The userdel command won’t work if the user is currently logged in or has processes running under the account. In this case, you have two options. You can either kill all the user’s processes with the killall command or use the -f option with the userdel command to force deletion.

$ sudo killall -u username
OR
$ sudo userdel -f username

The user should now be eradicated from the system after successful execution of the userdel command.

Was this answer helpful? 0 Users Found This Useful (0 Votes)