How to Create Batches of New Users

When you deploy a new dedicated server, you sometimes need to migrate your users from an old system.  While it is perfectly reasonable to manually add Linux users when there are only a few, adding a large number can be exhausting and time consuming.  Fortunately, the “newusers” command gives you the ability to add multiple users (50, 100, or even 500).

Normally, you would create a new user with the adduser command followed by the single username.  With newusers, you can use a file containing a list of your users.  The plain text file should have the following format with one user per line:


An example would be the following:

ssam:8jc91Nq:1003:1000:Serious Sam:/home/ssam:/bin/bash

Add more users on separate lines using the same format.  You may be able to use a spreadsheet or database program to export your user lists into the above format, making the process even faster.

Next, upload the file to your server to secure directory.  Finally, as root, run the command to add the new users:

newusers batch-users.txt

That is all it takes.  You will now have all of your users entered into your server without having to go through a step-by-step adduser process.  For more information about the newusers command, see the online documentation or type “man newusers” from the command line.