The useradd command can be used to create a users account in Linux.
Create user
The useradd command followed by username can be used to create a user account.
~]# useradd JohnDoe
Change password
The -p command can be used to create a password for the user.
~]# useradd -p MyPassword JohnDoe
Create home directory
The -d command can be used to create the users home directory. In this example, the home directory is /home/JohnDoe.
~]# useradd -d /home/JohnDoe JohnDoe
Create default shell
The -s command can be used create the users default shell (/bin/bash in this example).
~]# useradd -s /bin/bash JohnDoe
Join a group
The -G option can be used to add a new user to a group. In this example, JohnDoe is added to group1.
~]# useradd -G group1 JohnDoe
Add comment
The -c option can be used to add a comment. The comment is typically the users first and last name.
~]# useradd -c "John Doe" JohnDoe
View users account
The /etc/passwd file will contain the users account. Refer to Linux Files - Understanding the /etc/passwd file to view the users account.