1.创建个txt文件,写入要创建的用户名
[root@hya srcipts]# vim user.txt hya110 hya120 hya130
2.编写脚本
[root@hya srcipts]# vim 无交互改密.sh #/usr/bin/env sh for i in `cat user.txt` do useradd $i echo "1234" | passwd --stdin $i done [root@hya srcipts]# ./无交互改密.sh 更改用户 hya110 的密码 。 passwd:所有的身份验证令牌已经成功更新。 更改用户 hya120 的密码 。 passwd:所有的身份验证令牌已经成功更新。 更改用户 hya130 的密码 。 passwd:所有的身份验证令牌已经成功更新。
3.删除用户
[root@hya srcipts]# vim 删除普通用户脚本.sh #!/bin/bash for i in `cat user.txt` do userdel $i rm -rf /home/$i echo $i done 我们来看txt有哪些用户 [root@hya srcipts]# cat user.txt hya110 hya120 hya130 [root@hya srcipts]# sh 删除普通用户脚本.sh hya110 hya120 hya130
转载自:CSDN 作者:Hya、
原文链接:https://blog.csdn.net/yeyslspi59/article/details/108110866