Centos create new user
To create a new user on CentOS, you can use the useradd
command. Here are the steps:
- Open a terminal as the root user or use
sudo
to gain root privileges. - Use the following command to create a new user:
useradd <username>
Replace
<username>
with the desired username for the new user.
For example, to create a new user named "john", you would use the following command:
useradd john
- The
useradd
command will create a new user account with a default home directory and shell. You can customize the user's settings by using various options with theuseradd
command.
Some common options include:
-m
: Create a home directory for the new user.-s
: Specify the shell to use for the new user.-g
: Specify the primary group for the new user.-G
: Specify additional groups for the new user.
For example, to create a new user named "john" with a home directory and a custom shell, you would use the following command:
useradd -m -s /bin/bash john
-
To set a password for the new user, use the
passwd
command:passwd john
Replace
john
with the username of the new user. -
You can also use the
usermod
command to modify the properties of an existing user account.
For example, to change the shell for an existing user named "john" to /bin/zsh
, you would use the following command:
usermod -s /bin/zsh john
Note: The useradd
and usermod
commands are used to manage user accounts on CentOS. The passwd
command is used to set or change passwords for user accounts.