How to remove a user in Ubuntu?

To delete a user on Ubuntu, you can follow these steps:

  1. Open the terminal.
  2. By logging in with root privileges, you can use the following command to switch to the root user:
  3. Switch to superuser/root using the “su” command in Linux.
  4. Confirm that the user you want to delete does not have any open sessions. You can use the following command to list the currently logged in users and their sessions:
  5. whoever
  6. Delete the user using the following command:
  7. Delete the user along with their home directory: userdel -r username
  8. The username to be deleted is specified. The -r option will remove the user’s home directory.
  9. After removing the user, you can use the following command to confirm that the user has been deleted:
  10. Retrieve the user information by searching for the username in the /etc/passwd file.
  11. If the user information cannot be found, it means the user has been successfully deleted.

Please be aware that deleting a user is a sensitive operation, so please proceed with caution. Make sure you truly want to delete the user and backup any important user data.

bannerAds