To create a new user account in CentOS 7/8/9, you can use the useradd
command. The useradd
command is a standard Unix command that is used to create a new user account on the system.
Log in to your CentOS system as the root user.
Run the useradd
command with the desired username as an argument. For example, to create a new user account with the username myuser
, you can use the following command:
useradd myuser
This will create a new user account with the default settings, including a default home directory and a default group.
passwd
command. For example:passwd myuser
Follow the prompts to enter and confirm the password for the user.
usermod
command. For example, to set the user's full name and add the user to additional groups, you can use the following command:usermod -c "Full Name" -a -G group1,group2 myuser
This will set the user's full name to "Full Name" and add the user to the group1
and group2
groups.
-s
option. For example, to set the user's login shell to bash
, you can use the following command:usermod -s /bin/bash myuser
userdel
command. For example:userdel myuser
This will delete the user account and the user's home directory.
Keep in mind that you will need to have appropriate privileges to create, modify, and delete user accounts on the system. You may need to use the sudo
command to gain sufficient privileges.