Creating New Users in a Batch File

When positioning a brand new web server, it becomes necessary to move the existing users of the old server to the new server. If the amount of users are least, it is added simply to your new server manually, however if the users are massive in numbers like one 100, 200, 500, etc… then manually migrating the users may become a very time consuming task. Fortunately, a linux command “newusers” permits you to migrate multiple users in least time.

Usually, a brand new user is created using the “adduser” command, whereas using the “newusers” command, you’ll be able to add an entire file holding the users list. Create a plain text file (.txt) and embody the info of a user per line as per the subsequent format:

loginname:password:uid:gid:comment:home_dir:shell

For Example:

mac:abcxyz:1045:1021:Lazy Mac:/home/mac:/bin/bash

Same way, add multiple users data per line using a similar format. To create this method more faster, you’ll be able to use a spreadsheet or an easy database program so as to export the user list.

Once you’re finished the text file, upload it to your new web server to secured directory. Lastly, run the subsequent command as root so as to feature the new users to your new server.

newusers batch-users.txtb

That’s it ! You’ve got with success migrated the existing users to your new dedicated server in easy steps by using the “newusers” command.