Linux Batch create user's script

Source: Internet
Author: User
Tags stdin

#!/bin/bash


For user in ' Cat/home/opt/userlist.txt '

Do

Mkdir-p/app/ftp/issue/merdealfiles/$user/dealfiles

Mkdir-p/app/ftp/issue/merdealfiles/$user/dealfiles/applyarea

Mkdir-p/app/ftp/issue/merdealfiles/$user/dealfiles/resultarea

Mkdir-p/app/ftp/issue/merdealfiles/$user/dealfiles/checkfiles

chmod 770/app/ftp/issue/merdealfiles/$user/dealfiles/applyarea

Cat/home/opt/uidlist.txt |while Read UID

Do

Useradd-u $uid-G develop-d/app/ftp/issue/merdealfiles/$user $user-S/sbin/nologin

Done

echo "$user successfully!!!"

echo "$user" >>/etc/access/ftpusers

echo "$user" >>/etc/access/chroot_users

#echo Linux | passwd--stdin $user

mkpasswd >/home/opt/userpasswd.txt

Cat/home/opt/userpasswd.txt | While read passwd

Do

echo "$passwd" |passwd--stdin $user

echo "$PASSWD" >>/home/opt/userpasswd-f.txt

Done

Done


Uidlist.txt format

1122

1223


Userlist.txt format

Test

Test1


However, the script still has some minor problems, but for the time being, the script can be created in bulk based on the user name and UID already specified, and the random password can eventually be written to Userpasswd-f.txt.


Linux Batch create user's script

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.