October 26, 2020

Out Here In The Fields

…of musings and ramblings

Create Linux user accounts in bulk

1 min read

creating 1 or 2 new users on your system is a fairly simple task. But when you need to create 50 or 100 accounts on a system, creating it one by one by hand will surely annoy even the most patient sysadmin.

 

First, create a plain text file that contains all the informations required in a format of standard /etc/passwd file. For example, create a text file newuser.txt

[root@foxbat scripts] vi /root/newuser.txt

that contains:

ambon:afd43:673:673::/home/ambon:/bin/bash
amurang:ixl89:674:674::/home/amurang:/bin/bash
bandungcc:cfr45:675:675::/home/bandungcc:/bin/bash
baubau:ndk73:676:676::/home/baubau:/bin/bash

“ambon” is the account name, “afd43” is the new password for the account, “636” refers to the account UID & GID. I skipped on the user info and leave it as blank. Next,  the “/home/ambon” is the path to the home directory of that particular account, and “/bin/bash is the path to the account shell. Please note that since the password on this plain text is not encrypted, make sure that root and only root is the only user that has access to this file. You can chmod 600 this file to prevent access from another account.

Next, create the accounts by simply doing:

[root@foxbat scripts] newusers /root/newuser.txt

..And we’re done!

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © All rights reserved. | Newsphere by AF themes.