How do you add a new user in CentOS?

Learn how to add a new user in CentOS with step-by-step instructions. Create user accounts and manage permissions easily on your CentOS system.

 How do you add a new user in CentOS?
Adding a New User in CentOS

Adding a New User in CentOS

Adding a new user in CentOS involves several steps. Below is a detailed guide on how to add a new user in CentOS:

Step 1: Log in as Root

Before adding a new user, you need to log in to your CentOS system as the root user. You can do this by opening a terminal and entering the following command:

sudo su -

You will be prompted to enter the root password. Once you have successfully logged in as the root user, you can proceed with adding a new user.

Step 2: Add a New User

To add a new user, you can use the adduser command. Here's the syntax for adding a new user:

adduser <username>

Replace <username> with the username you want to create for the new user. For example, to create a user named "john", you would use the following command:

adduser john

After running the adduser command, you will be prompted to set a password for the new user and enter additional information such as the user's full name, phone number, etc. You can either enter this information or leave it blank by pressing Enter.

Step 3: Assign a Password to the New User

After creating the new user, you need to set a password for the user. You can do this using the passwd command. Here's how you can set a password for the new user:

passwd <username>

Replace <username> with the username of the new user you created. For example, to set a password for the user "john", you would use the following command:

passwd john

You will be prompted to enter and confirm the new password for the user. Once you have successfully set the password, the new user will be able to log in to the system using the username and password you have created.

Step 4: Assign Additional User Information (Optional)

If you want to assign additional information to the new user, such as the user's full name, phone number, etc., you can use the usermod command. Here's the syntax for adding additional information to the user:

usermod -c "Full Name" -p Phone_Number <username>

Replace "Full Name" with the full name of the user and Phone_Number with the phone number of the user. For example, to add the full name "John Doe" and phone number "123-456-7890" to the user "john", you would use the following command:

usermod -c "John Doe" -p 123-456-7890 john

By adding additional information to the user, you can provide more context about the user for administrative purposes.

Step 5: Assign User to Groups (Optional)

If you want to assign the new user to specific groups, you can use the usermod command. Here's the syntax for adding a user to a group:

usermod -aG <groupname> <username>

Replace <groupname> with the name of the group you want to add the user to and <username> with the username of the user. For example, to add the user "john" to the "sudo" group, you would use the following command:

usermod -aG sudo john

By adding the user to specific groups, you can control the user's access to certain resources and permissions on the system.

Step 6: Verify the New User

Once you have added the new user and completed any additional

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow