「Linux入門」複数のユーザを一括作成するshellコード

サンプルコード
#!/bin/bash
#this shell is use to bachusers
if [ $# != 1 ];then
echo “Usage:root/batchusers"
elif [ -f $1 ];then
for line in `cat $1`
do
name=`echo $line | cut -d : -f1`
useradd -s /bin/bash $name
echo “123" | passwd –stdin $name
chage -d 0 -M 90 -W 7 -I 2 $name
echo “created user: $name"
done
else
echo “input file not found"
fi

Linux

Posted by arkgame