shell/自主创建用户密码.txt

21 lines
535 B
Plaintext
Raw Normal View History

2024-05-30 20:48:06 +08:00
#!/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