Shell password setting script when adding a user

Source: Internet
Author: User
Viuseradd. sh #! /Bin/bashi = 1 while [$ i-le5] douseraddred $ ia = 'sh. /passwd. sh 'echo & quot; red $ I: $ a & quot; & gt; userpasswdechored $

Vi useradd. sh
#! /Bin/bash
I = 1
While [$ I-le 5]
Do
Useradd red $ I
A = 'sh./passwd. Sh'
Echo "red $ I: $ a"> userpasswd
Echo red $ I: $ a | chpasswd
Let I ++
Done

Run sh useradd. sh.

[Root @ 2 shell] # cat/etc/passwd | grep red
Red1: x: 515: 515:/home/red1:/bin/bash
Red2: x: 516: 516:/home/red2:/bin/bash
Red3: x: 517: 517:/home/red3:/bin/bash
Red4: x: 518: 518:/home/red4:/bin/bash
Red5: x: 519: 519:/home/red5:/bin/bash
[Root @ 2 shell] # cat userpasswd
Red1: $ Ca7 % 298d2
Red2: eEaBBB7Fb4
Red3: % 3e1_cece
Red4: 3 @ F % @ B0584
Red5: AdEe ^ 6BF $ F
[Root @ 2 shell] # su red1
[Red1 @ 2 shell] $ su red2
Password:
[Red2 @ 2 shell] $

############# The shell of passwh. sh in this blog randomly generates ten password scripts ############


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.