From: Ertugrul Soeylemez on 19 Jun 2006 19:19 Michael Heiming <michael+USENET(a)www.heiming.de> (06-06-19 23:24:09): > But why the hassle? You can script useradd to do the job more easily > for you. As usual the fine manual 'man useradd' has the info. Yes, and it's also more portable and optionally allows automatic home directory creation based on a template, and so on. You shouldn't tamper with /etc/passwd, /etc/group and /etc/shadow, unless you have a good reason to do so. Use system tools instead. To get you started: for n in `seq 0 8999`; do useradd -u $((1000 + $n)) -g $((1001 + $n / 1000)) user_$((1000 + $n)) done Regards, E.S.
From: Michael Heiming on 19 Jun 2006 20:08 In comp.os.linux.networking Chris F.A. Johnson <cfajohnson(a)gmail.com>: > On 2006-06-19, Michael Heiming wrote: >> In comp.os.linux.networking Ross <nospam(a)ross.com>: >> >>> "Bit Twister" <BitTwister(a)mouse-potato.com> wrote in message >>>> On Mon, 19 Jun 2006 16:42:01 -0400, Ross wrote: >>>>> Hi there, >>>>> I am going to create 9000 users. >> [ short bash script to do it ] >> >>>> http://tldp.org/LDP/abs/html/index.html >> >>> Thanks a lot for your idea! >>> But the $user comes with new line. The output is like this: >>> user_1^M:x:1001:1000::/home/user_1^M:/bin/bash >>> user_2^M:x:1002:1001::/home/user_2^M:/bin/bash >>> : >> >>> How could I eliminate the ^M? >> >> Don't keep your files on a doze box, those can't even handle a >> text file probably, > s/probably/properly/ Thx for reminding! ;-) > There is nothing improper about a Windows text file; the standard > allows CR/LF line endings. Just that it sucks if you edit/transfer text on one and copy to the other. Strange enough there's zero problem between any kind of unix system. Just M$ has this problem, perhaps because it isn't an OS but a fine? ;-) >> as you just encountered. Alternatively run >> 'dos2unix' over the file. So much for standards... -- Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94) mail: echo zvpunry(a)urvzvat.qr | perl -pe 'y/a-z/n-za-m/' #bofh excuse 246: It must have been the lightning storm we had (yesterday) (last week) (last month)
From: Chris F.A. Johnson on 20 Jun 2006 13:47 On 2006-06-19, Ertugrul Soeylemez wrote: > Michael Heiming <michael+USENET(a)www.heiming.de> (06-06-19 23:24:09): > >> But why the hassle? You can script useradd to do the job more easily >> for you. As usual the fine manual 'man useradd' has the info. > > Yes, and it's also more portable It is not portable; there are different versions, with different syntax, even among Linux distros. Other *nixen may not have it at all. -- Chris F.A. Johnson, author <http://cfaj.freeshell.org> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence
From: Ross on 20 Jun 2006 15:58 Thanks a bunch to all guys! Your replies are very helpful! Ross "Ross" <nospam(a)ross.com> wrote in message news:UeOdndoExoWHkQrZnZ2dnUVZ_q-dnZ2d(a)magma.ca... > Hi there, > I am going to create 9000 users. > I have all the user names in a txt file userlist.txt like this: > user_1 > user_2 > : > user_9000 > > I want the passwd file to be created like this: > user_1:x:1001:1000::/home/user_1:/bin/bash > user_2:x:1002:1000::/home/user_2:/bin/bash > : > user_1000:x:1001::/home/user_2000:/bin/bash > : > user_9000:x:1009::/home/user_9000:/bin/bash > > How could I use bash with something like awk to create the passwd file? > And also the group, shadow files (all passwords can be the same)? > Thanks, > Ross >
From: Michael Heiming on 20 Jun 2006 16:15 In comp.os.linux.networking Ertugrul Soeylemez <never(a)drwxr-xr-x.org>: > Michael Heiming <michael+USENET(a)www.heiming.de> (06-06-19 23:24:09): >> But why the hassle? You can script useradd to do the job more easily >> for you. As usual the fine manual 'man useradd' has the info. > Yes, and it's also more portable and optionally allows automatic home If more portable or not, 'useradd' should ease up things tremendously. Basically the versions of useradd on many unix[tm] work the same as the Linux version, the later has a nice option to hand over a crypt() string as password. Haven't seen this option in any other unix[tm], though it might have been added since I checked. Halfway recent *BSD versions can do the same through 'pw' (iirc). No rocket science to rewrite with awk one version to another. > directory creation based on a template, and so on. You shouldn't tamper > with /etc/passwd, /etc/group and /etc/shadow, unless you have a good > reason to do so. Use system tools instead. Indeed, strange enough the better idea of doing so occurred me just after typing the line awk. > To get you started: > for n in `seq 0 8999`; do > useradd -u $((1000 + $n)) -g $((1001 + $n / 1000)) user_$((1000 + $n)) > done Nice line of bash. ;-) -- Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94) mail: echo zvpunry(a)urvzvat.qr | perl -pe 'y/a-z/n-za-m/' #bofh excuse 134: because of network lag due to too many people playing deathmatch
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: dhcpd.conf setup Next: prism 2.5 chipset config. 4 ubuntu |