Add users on the Linux command line
To add new user on any Linux command line is a breeze. The following command should work on most Linux distributions. On CentOS I know the default installation does not have the directory /usr/sbin on the path by default. To get around it you just need to run the useradd command using /usr/sbin/useradd. If that still does not work you can use the locate tool to find it.
The command to add a user on the Linux command line is as follows:
# become root su useradd -d /home/userdir -s /bin/bash -c "users full name" username
The above useradd command is telling Linux to create a home directory (make sure to replace userdir with yours). The we want to use /bin/bash as our default shell and also we want to set the full name of the user. Then the line ends with the username that we want to use to log into Linux.
To set the password for the user we have just created, as root, run the following command:
The above command will ask you for a new password and then will ask you to repeat it.