Remove Linux User

A common system administration task that you may need to perform on a Linux server is removing a user account. It is very easy to remove a user. The steps below will quickly outline the commands and procedures to do so. Removing old and inactive user accounts is an important security process as it reduces the potential attack surface.

  1. Access the server via SSH.
  2. Switch to root:
    sudo su -
  3. The userdel command safely deletes the specified user:
    userdel <username>
  4. You may also delete the user’s home directory and mail spool with the optional¬†-r flag.
    userdel -r <username>

    Warning:¬†This command cannot be undone so only delete a user’s home directory if you no longer need access to their files or mail.

Leave a Reply

Your email address will not be published. Required fields are marked *