First, the project needs
Batch Create 10 user Stu01-stu10, and set a random 8-bit password, require: Not with Shell loop (for example: For,while, etc.), can only be implemented with Linux commands and pipelines.
Ii. Method of realization (i)
1) Create an account and set a random password
[[email protected] ~]# for n
seq 10
;d o useradd user$n;echo "user$n
echo user$n|md5sum|cut -c4-8
"|PASSWD--stdin User$n;done
2) Print the password and import the file
[[email protected] ~]# for n
seq 10
;d o echo "user$n
echo user$n|md5sum|cut -c4-8
";d one>>/tmp/tim1
3) Print the user and import the file
[[email protected] ~]# for n
seq 10
;d o echo user$n;done>>/tim2
4) Merging user password files
[Email protected] ~]# paste-d ":"/tim2/tmp/tim1 >>/tmp/newpasswd
[Email protected] ~]# CAT/TMP/NEWPASSWD
user1:user193167
User2:user22d1d7
user3:user3c489e
user4:user44890e
user5:user5ca814
User6:user6957ba
User7:user72c5fb
user8:user83428e
user9:user949703
user10:user100dc3e
Third, the realization Method (ii)
1) Create a user and set a password
[[email protected] ~]# for n
seq 11 16
;d o useradd user$n;echo "user$n:user$n
echo user$n|md5sum|cut -c4-8
"|chpasswd;done
[Email protected] ~]# tail-6/etc/passwd
User11:x:517:517::/home/user11:/bin/bash
User12:x:518:518::/home/user12:/bin/bash
User13:x:519:519::/home/user13:/bin/bash
User14:x:520:520::/home/user14:/bin/bash
User15:x:521:521::/home/user15:/bin/bash
User16:x:522:522::/home/user16:/bin/bash
2) export user password to file
[[email protected] ~]# for n
seq 11 16
;d o echo "user$n:user$n
echo user$n|md5sum|cut -c4-8
";d ONE>>/TMP/NEWPASSWD1
[Email protected] ~]# CAT/TMP/NEWPASSWD1
user11:user11b755c
User12:user121deb5
user13:user13f627d
user14:user1472383
user15:user15c5412
user16:user16eb606
Linux batch Create user and set random password