IntroductionAs a Linux system administrator, you will sometimes have to add new user account to your system. To do so,
addusercommand is often used. When it comes to multiple users' creation,
addusercommand 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
newuserscommand will help you to create multiple users by getting their info from a prefilled file.
RequirementsPrivileged access to your Linux machine
Conventions# - 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 usernamesIn 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.txtPut 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 ...
Create usersAfter having created the previous file with predefined users info, use
newuserscommand to create users.
# newusers users-list.txt
Check user accountsFinally you can confirm that the users were created correctly, by looking for their presence in the
# tail /etc/passwd