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.