As a Linux system administrator, you will sometimes have to add new user account to your system. To do so,
adduser command is often used. When it comes to multiple users’ creation,
adduser command may become boring and time-consuming.
This short article intends to provide the Linux system administrator with a simple and unattended way for bulk user creation. The
newusers command will help you to create multiple users by getting their info from a prefilled file.
Privileged access to your Linux machine
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to proceed
Create a file containing the usernames
In this initial step, you need to create a file that will contain the list of the usernames that are to be created.
$ vi users-list.txt
Put in your file, one user info per line, following the pattern below:
Username:Password:User ID:Group ID:User Info:Home Directory:Default Shell Username:Password:User ID:Group ID:User Info:Home Directory:Default Shell Username:Password:User ID:Group ID:User Info:Home Directory:Default Shell ...
After having created the previous file with predefined users info, use
newusers command to create users.
# newusers users-list.txt
Check user accounts
Finally you can confirm that the users were created correctly, by looking for their presence in the
# tail /etc/passwd