How to Create a new user account in CentOS 7/8/9

In CentOS 7/8/9, you can create a new user account using the useradd command, which is a command-line utility for adding new users to the system. Here are the steps to create a new user account:

  1. Open a terminal window and log in as the root user or use the sudo command to run the following commands.
  2. To create a new user, use the useradd command followed by the username. For example:
useradd newuser
  1. To set a password for the new user, use the passwd command followed by the username. For example:
passwd newuser

This command will prompt you to set the password for the new user.

  1. To add the user to a group, use the usermod command followed by the -aG option and the group name. For example:
usermod -aG groupname newuser
  1. To set the home directory for the new user, use the -d option with the useradd command. For example:
useradd -d /home/newuser newuser
  1. To change the default shell for the new user, use the -s option with the useradd command. For example:
useradd -s /bin/bash newuser
  1. Finally, you can check your new user is created by using the id command followed by the username or cat /etc/passwd to see all the system’s users.

It’s important to note that, these are the basic steps to create a new user, but you can also customize and add more options according to your needs. Also, remember that creating a new user with a strong and unique password is a must for security reasons.

Leave a Comment