To create new users in Linux, you can use the useradd command. Here’s how to do it:
-
Open a terminal.
-
Use the
useraddcommand followed by the username you want to create. For example, to create a user namednewuser, you would run:sudo useradd newuser -
Set a password for the new user using the
passwdcommand:sudo passwd newuserYou will be prompted to enter and confirm the new password.
-
(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.
-
Verify the user creation by checking the
/etc/passwdfile:grep newuser /etc/passwd
This will display the details of the newly created user if the creation was successful.
