Remove or delete a Linux user
You can remove old users from your Linux server. This will revoke the user's SSH access, and remove that user's file and directory ownership. To delete a user in Linux, follow these steps.
Note: This procedure should work for all Linux distribution types - Ubuntu, CentOS, and so on.
- Log in to your server via SSH.
- Switch to the root user:
sudo su - - Use the userdel command to remove the old user:
userdel user's username - Optional: You can also delete that user's home directory and mail spool by using the -r flag with the command:
userdel -r user's usernameWarning: Only delete a user's home directory if you are certain you no longer need their files or mail.
Next step
- For more detailed information about the userdel command, view the man page by typing
man userdel
into your SSH window.