美文网首页每日python三分钟
30-shell脚本创建用户并设置密码

30-shell脚本创建用户并设置密码

作者: JSFnull | 来源:发表于2019-12-14 09:48 被阅读0次

#!/bin/bash

read -p "请输入用户名:" name

if [ -z $name ]; then

echo "必须输入用户名"

exit

fi

read -p "请输入密码:(默认密码为123)" pass

pass=${pass:-123}

useradd "$name"

echo "$pass" | passwd --stdin "$name"

userdel "$name"

相关文章

网友评论

    本文标题:30-shell脚本创建用户并设置密码

    本文链接:https://www.haomeiwen.com/subject/dyjlgctx.html