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:
- Open a terminal window and log in as the root user or use the
sudo
command to run the following commands. - To create a new user, use the
useradd
command followed by the username. For example:
useradd newuser
- 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.
- 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
- To set the home directory for the new user, use the
-d
option with theuseradd
command. For example:
useradd -d /home/newuser newuser
- To change the default shell for the new user, use the
-s
option with theuseradd
command. For example:
useradd -s /bin/bash newuser
- Finally, you can check your new user is created by using the
id
command followed by the username orcat /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.