#!/bin/bash
for i in $(awk -F" " ‘{ print $2 }‘ user.list | sed ‘s/,/\n/g‘ | sort -u) ; do echo "groupadd $i" ; done
while read U_NAME G_NAME HOME_DIR
do
echo "mkdir $(dirname $HOME_DIR)"
echo "useradd -g $(echo $G_NAME | cut -d, -f1) -G $G_NAME -d $HOME_DIR $U_NAME"
echo "usermod -g $(echo $G_NAME | cut -d, -f1) -G $G_NAME -d $HOME_DIR $U_NAME"
done < user.list
while read U_NAME U_PASSWORD
do
if [ -z $U_PASSWORD ]
then
echo "echo \"1234\" | passwd --stdin $U_NAME"
else
echo "echo \"$U_PASSWORD\" | passwd --stdin $U_NAME"
fi
done < passwd.list
时间: 2024-10-09 11:13:27