Create a new user on Linux with the command line
Creating a new user on Linux with the command line is very easy. Just use the useradd command and this will be accomplished very easily.
Use this command to create a new user account.
ubuntu ~ $ sudo useradd -d /home/jeff -s /bin/tcsh -m jeff
Then set a password this way. If you try to set a password like this.
ubuntu ~ $ sudo useradd -d /home/jeff -p passwordjeff -s /bin/tcsh -m jeff
It will not work, you have to create the account first, then set the password afterwards.
ubuntu ~ $ sudo passwd jeff Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
Then I can log in as the new user.
ubuntu ~ $ su jeff Password: ip-172-31-20-16:/home/ubuntu>
This is how easy it is to create a new user account on Linux with the useradd command. This could be used in a script to create a few accounts at a time.