≡ Menu

How to remove a Linux user account?

The question is – is there a command in Linux based systems to remove a user’s account from the system? Is there a way to disable a user account?

There are two commands that can be used here. The first command is called userdel which removes users from a Linux box. The other command is called passwd which can be used to lock or disable a user in the system.

How to lock or disable a user?

To lock or disable a user, use the passwd command with the -l option:

passwd -l username

To unlock or enable the user access to the system, use the passwd command with the -u option:

passwd -u username

How to delete the user from the Linux box entirely?

Once you have locked the user from the box, you can delete the user:

userdel username

This will remove the user, but the files in the home directory will still exist.

To remove all files in the home directory of the user, use the -r option to userdel:

userdel -r username

Note that this will remove all the user’s files entirely from the system, so make sure that you create a backup of the files before using this command!

{ 0 comments… add one }

Leave a Comment