Batch import samba user and password scripts

Source: Internet
Author: User
Because we recently set up samba, we all know that samba users must actually exist in the system. when many users want to create samba, and the password is assigned to you, at this time, only shell scripts can be used for processing. in the format shown in the figure below, all the odd lines are usernames and even lines are passwords. this is our user and password file. shell script content: viuseradd. sh #! /Bin/bashfornamein 'a because we recently set up samba, we all know that samba users must actually exist in the system. when many users want to create samba, and the password is also specified for you, at this time, only shell scripts can be used for processing.
In the format shown in the figure below, all the odd lines are usernames and even lines are passwords. this is our user and password file.
Shell script content:
Vi useradd. sh
#! /Bin/bashfor name in 'awk' NR % 2 = 1'/root/user.txt 'douseradd-d/home/$ {name}-s/bin/bash $ {name} doneawk 'NR % 2 = 0' user.txt> pass.txt awk 'NR % 2 = 1' user.txt> t.txt awk 'NR = FNR {a [I] = $ 0; I ++} NR> FNR {print a [j] "" $0; j ++} 't.txt pass.txt> test.txt sed's/[[: space:] [[: space:] */:/g' test.txt> passwd.txt chpasswd
 
  
The script is easy to write, but you only need to achieve the goal. of course, if you have your own requirements, you can modify it yourself.
Related Article

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.