Create new user centos
Here are the steps to create a new user on a CentOS system:
Method 1: Using the useradd
command
- Open a terminal as the root user (or use
sudo
to elevate your privileges). - Type the following command to create a new user:
useradd <username>
- Replace
<username>
with the desired username for the new user.
- Replace
- Set the password for the new user using the
passwd
command:passwd <username>
- Enter a password for the new user, and then confirm it.
- Verify that the new user has been created by running the
id
command:id <username>
Method 2: Using the adduser
command (CentOS 7 and later)
- Open a terminal as the root user (or use
sudo
to elevate your privileges). - Type the following command to create a new user:
adduser <username>
- Replace
<username>
with the desired username for the new user.
- Replace
- Set the password for the new user using the
passwd
command:passwd <username>
- Enter a password for the new user, and then confirm it.
- Verify that the new user has been created by running the
id
command:id <username>
Additional options
You can also specify additional options when creating a new user, such as:
-m
to create a new home directory for the user-s
to specify the shell for the user (e.g./bin/bash
)-G
to specify the group(s) for the user to belong to
For example:
useradd -m -s /bin/bash -G wheel <username>
This would create a new user with a home directory, use the Bash shell, and add the user to the wheel
group.
Verify the new user
Once you've created the new user, you can verify that they exist by running the id
command:
id <username>
This should display information about the new user, including their username, user ID, and group membership.
That's it! You should now have a new user on your CentOS system.