This is a discussion on How to create multiple user account? within the Shell scripting forums, part of the Development/Scripting category; I found the link to create multiple user account by typing out all the account. But how to create using ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
I found the link to create multiple user account by typing out all the account. But how to create using linux shell scripting if i want to create 50 account which are almost the same but only difference is the user number and some other number is different which is in running order?
Eg. First user will have the following details: Login name: user00 Password: pwd00 UID: 1000 GID: 123 Informational name: “Student Index 00” Home directory: /home/SI00 Login shell: /bin/sh the last user will have the following details: Login name: user49 Password: pwd49 UID: 1049 GID: 123 Informational name: “Student Index 49” Home directory: /home/SI49 Login shell: /bin/sh Last edited by droidwork; 06-08-2007 at 08:25 PM.. |
| Sponsored Links | ||
|
|
|
||||
|
You need to use newusers command and a text file with this info.
data.txt file Code:
user00:pwd00:1000:123:Student Index 00:/home/SI00:/bin/sh user01:pwd00:1001:123:Student Index 01:/home/SI01:/bin/sh ..... ... .. user49:pwd49:1049:123:Student Index 49:/home/SI49:/bin/sh Code:
for u in $(seq 00 05); do echo "user${u}:pwd${u}:$(expr 1000 + $u):123:Student Index ${u}:/home/SI${u}:/bin/sh"; done > data.txt
Code:
newusers data.txt PS: If you are doing this first time, make a backup of all all password related files aka /etc/passwd, /etc/group, /etc/shadow and others |
|
|||
|
Quote:
00-49 wil create 50 users from 00,01,02..49 In short use Code:
for u in $(seq 00 49); do echo "user${u}:pwd${u}:$(expr 1000 + $u):123:Student Index ${u}:/home/SI${u}:/bin/sh"; done > data.txt
__________________
Raj Linux rulz. I have never turned back in my life ; I shall not do so today.. haha |
|
|||
|
somehow i cant get it to work.. it create only 1 funny account and not.. mayb can someone teach me step by step?
i write the code in vi data.txt.. then after :wq!, use newusers data.txt.. is this the right way? Last edited by droidwork; 06-12-2007 at 05:31 PM.. |
|
|||
|
Noop..
Login as root user goto /tmp Code:
cd /tmp Code:
for u in $(seq 00 49); do echo "user${u}:pwd${u}:$(expr 1000 + $u):123:Student Index ${u}:/home/SI${u}:/bin/sh"; done > data.txt
Now just add new users Code:
newuser data.txt
__________________
Raj Linux rulz. I have never turned back in my life ; I shall not do so today.. haha |
|
|||
|
thank you very much.. anyway can tell me what does $(expr 1000 + $u): do? i know u is for the value.. and 1000 is the starting.. but what does expr for?
Last edited by droidwork; 06-12-2007 at 06:41 PM.. |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unable to create user | vaibhav.kanchan | Getting started tutorials | 3 | 12-07-2007 11:46 AM |
| how to create super user | click007 | Getting started tutorials | 12 | 08-28-2007 09:14 PM |
| Create new user account in Ubuntu Linux from command line | sweta | Getting started tutorials | 0 | 06-21-2007 02:49 AM |
| HP UX creating user account with SAM - it is easy to use | rockdalinux | HP-UX | 0 | 12-20-2006 03:01 PM |
| how to create multiple file in a single command | selvam | Shell scripting | 3 | 07-26-2006 02:01 AM |