The Problem

Unable to remove a user and userdel throws the below error:

# userdel -r username
userdel: user username is currently used by process xxx

The Solution

New child processes are being created every time the ‘userdel’ command is run and hence unable to remove the user.

You can use the below commands to forcefully remove the user.

# killall -TERM -u username
# userdel -f username

The -f would forcefully remove this user, including the user’s home directory/mail (if any). So, use this option only if you are aware of what gets removed for this specific user. When using -f option, you need not use the -r option.