How to create new users?

QuestionsQuestions8 SkillsProYour First Linux LabSep, 02 2025
0182

To create new users in Linux, you can use the useradd command. Here’s how to do it:

  1. Open a terminal.

  2. Use the useradd command followed by the username you want to create. For example, to create a user named newuser, you would run:

    sudo useradd newuser
  3. Set a password for the new user using the passwd command:

    sudo passwd newuser

    You will be prompted to enter and confirm the new password.

  4. (Optional) Specify additional options: You can customize the user creation by adding options. For example, to create a user with a home directory and a specific shell, you can use:

    sudo useradd -m -s /bin/bash newuser
    • -m: Creates a home directory for the user.
    • -s: Specifies the default shell for the user.
  5. Verify the user creation by checking the /etc/passwd file:

    grep newuser /etc/passwd

This will display the details of the newly created user if the creation was successful.

0 Comments

no data
Be the first to share your comment!