Linux add new user
To add a new user in Linux, you can use the useradd
command. Here are the basic steps:
- Open a terminal as the root user or use
sudo
to gain root privileges. - Type the following command to add a new user:
useradd <username>
Replace
<username>
with the desired username for the new user.
For example:
useradd john
This will create a new user account with the default settings.
- To set a password for the new user, use the
passwd
command:passwd <username>
Replace
<username>
with the username you created in step 2.
For example:
passwd john
You will be prompted to enter a password for the new user.
- To add the new user to a specific group, use the
usermod
command:usermod -aG <group> <username>
Replace
<group>
with the name of the group you want to add the user to, and<username>
with the username you created in step 2.
For example:
usermod -aG wheel john
This will add the user john
to the wheel
group.
- To verify that the new user has been created, use the
id
command:id <username>
Replace
<username>
with the username you created in step 2.
For example:
id john
This will display information about the new user, including their username, user ID, and group membership.
That's it! The new user should now be created and ready to use.
Note: You can also use the adduser
command instead of useradd
, but useradd
is the more traditional and widely used command.