21 lines
535 B
Bash
21 lines
535 B
Bash
#!/usr/bin/bash
|
|
|
|
read -p "请输入你要添加的账号:" user
|
|
read -s -p "请输入你要修改的密码:" passwd
|
|
|
|
id $user &>/dev/null
|
|
|
|
if [ $? -eq 0 ];then
|
|
|
|
echo "user $user \ 已经存在了"
|
|
echo "密码稍后可以重置"
|
|
sleep 1
|
|
echo "密码修改完成了"
|
|
echo $passwd | passwd --stdin $user &>/dev/null
|
|
else
|
|
useradd $user
|
|
echo $passwd | passwd --stdin $user &>/dev/null
|
|
echo "新用户添加成功,密码修改完成"
|
|
|
|
|
|
fi |