Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Creating Bulk users in Linux :)  (Read 4225 times)

0 Members and 1 Guest are viewing this topic.

sajay

  • Guest
Creating Bulk users in Linux :)
« on: October 25, 2013, 12:41:34 am »
In huge Organisation's some times we need to create multiple users at the same time .
Linux offers a way to upload users using "newusers" command non-interactively.

Eg:
Create text file .This file format is same as the password file "/etc/passwd"

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

vi users.txt
testuser1:user1!@#:1001:1000:testuser1 Tester:/home/testuser1:/bin/bash
testuser2:user2!@#:1002:1000:testuser2 Tester:/home/testuser2:/bin/bash
testuser3:user3!@#:1003:1000:testuser3 Tester:/home/testuser3:/bin/bash
testuser4:user4!@#:1004:1000:testuser4 Tester:/home/testuser4:/bin/bash
testuser5:user5!@#:1005:1000:testuser5 Tester:/home/testuser5:/bin/bash

NB: This file must be protected since it contains unencrypted passwords.
      System default encryption algorithm for encrypting passwords defined in /etc/login.defs are used by default for encrypting passwords.

or

newusers -c (--crypt-method) can be used to define the Encryption Algortihm DES/ MD5/SHA256/SHA512
         
Run

newusers users.txt

The users are being successfully uploaded .

NB:system default encryption algorithm for encrypting passwords defined in /etc/login.defs are used by default.

cat /etc/passwd

testuser1:x:1001:1000:testuser1 Tester:/home/testuser1:/bin/bash
testuser2:x:1002:1000:testuser2 Tester:/home/testuser2:/bin/bash
testuser3:x:1003:1000:testuser3 Tester:/home/testuser3:/bin/bash
testuser4:x:1004:1000:testuser4 Tester:/home/testuser4:/bin/bash
testuser5:x:1005:1000:testuser5 Tester:/home/testuser5:/bin/bash

cat /etc/shadow

testuser1:$6$Szr/PZw6qV9B$leCsYlIcfTy8UGv22GDN.uwW72m6tK0bnyFzT93ceCX.EMZdz99sbLSUyFXoPeLYDAP1lL7VpI12.QIiH6Jvt/:15995:
testuser2:$6$8zycg94qmY$9TfBFH.7/ekbVaTMCaZP6t6SCHapfeC8LxMB4UCYDy5jKRhKEApCy7ScXjI1CO2mVYzJ9i3RMfIOY33U63YrC.:15995:
testuser3:$6$NLcl4cB9$bBa5EeH13fU.xUgBoU8fwRohB9dWXdiT8gSstc3ajakZrcR4/qWT1PAEy4JZM0loMVx8HaZxW8qlLUwX2DMLf0:15995:
testuser4:$6$7V9Nymwutd/$NCvV3XyN51yZaIog9brXKdZbtTWj3M9iKY7Sp1CXQ2tbOdUNuUYjh74cKRi0Eeax4T9UkpH8q6GONfX1BY1xg1:15995:
testuser5:$6$CahkZ/sN.3RTSAC$ZxbkeXgrct3AI2zilXS1Hvy/YV42miHAY.0nzVnlZRkSa7xdVa21wdWwXLQPBOpSKM5x.DB3UjAQJXR7m07n41:15995:

Thank you,
 :) :) :)