Linux User Management: How to Delete Users and Create Admin Accounts

Managing user accounts is a fundamental task for Linux system administrators. This guide provides clear, step-by-step instructions to:

  • Create new admin (sudo) users
  • Delete users and their home directories
  • Verify permissions and troubleshoot common issues

Whether you’re cleaning up old accounts or setting up a new system, these commands ensure proper user management while maintaining security. All examples include terminal snippets ready for copy-pasting.

How to Create a New Admin User in Linux

To create a new admin (sudo) user, follow these steps:

sudo adduser newusername

Follow prompts to set a password and user details. Make sure to replace newusername in command with your desired username.

sudo usermod -aG sudo newusername #Debian/Ubuntu

or

sudo usermod -aG wheel newusername #CentOS/RHEL

su - newusername
sudo whoami #Should return “your user”

If using SSH, ensure the new user can log in:
sudo cp -r ~/.ssh /home/newusername/
sudo chown -R newusername:newusername /home/newusername/.ssh

Delete User/Admins account

To delete a user and their home directory in Linux, follow these steps and run relevant command:

sudo ps -u osboxes

sudo killall -u osboxes

sudo userdel -r osboxes

-r removes the user’s home directory and mail spool.

sudo ls /home #Check if home directory is deleted
id osboxes #Check if user still exists (should return “no such user”)

Alternative: Manage Users via GUI Settings

While terminal commands offer precision, Linux also provides graphical tools to delete users and create admin accounts:

  1. Open SettingsUsers & Groups (or System SettingsUser Accounts).
  2. To Delete a User:
    • Select the user → Click "Remove" or the minus (-) button.
    • Check "Delete Files" to remove the home directory.
  3. To Create an Admin:
    • Click "Add User" → Set account type to "Administrator".
    • Assign a password and permissions.

Note: GUI options vary by distro (GNOME/KDE) and require sudo privileges. For servers or advanced control, terminal commands remain essential.

  • Donate This Project

    You can keep this project alive by donation or disable your “Adblocker” for this website. Thank You!