How to Create and Manage Users in Linux

August 18, 2025 / Web Hosting

This guide covers how to create, modify, and delete user accounts using common Linux commands.

Managing users in Linux is important for maintaining security, access control, and system organisation.

Let us follow the guide:

  1. To create a new user:
    1. Use the ‘useradd’ command followed by the username:
      sudo useradd username
    2. Set a password for the new user:
      sudo passwd username
    3. For instance:
      sudo useradd john
      sudo passwd john
  2. To create a user with a home directory:
    Some distributions require the ‘-m’ option to create a home directory automatically:

    sudo useradd -m username
  3. To add an existing user to a specific group, execute the following:
    sudo usermod -aG groupname username

    Example:

    sudo usermod -aG sudo john

    (This grants ‘john’ administrative privileges.)

  4. To modify a user’s details, such as their shell or home directory, run the following:
    sudo usermod -s /bin/bash john
    sudo usermod -d /new/home/path john
  5. To display user account details:
    id john
  6. To delete a user but keep their files:
    sudo userdel john
  7. To delete a user and their home directory:
    sudo userdel -r username

In this manner, you can create, modify, and remove users in Linux using simple commands like useradd, usermod, and userdel, ensuring secure and organised system management.

Want to secure your WordPress site too? Learn How to change the WordPress admin username

Spread the love