Linux->User Manager
1、不与Linux交互,直接添加用户密码
View Code
[root@DG1 shell]# useradd user01 [root@DG1 shell]# echo 123456 | /usr/bin/passwd --stdin user01 更改用户 user01 的密码 。 passwd: 所有的身份验证令牌已经成功更新。
2、批量添加、删除用户脚本
批量添加
#!bin/sh # Author:ArcerZhang <E-mail:arcerzhang@163.com> # The script to add user # /etc/passwd info echo "please input username:" read name echo "please input number:" read num n=1 while [ $n -le $num ] do /usr/sbin/useradd $name$n n=`expr $n + 1` done # /etc/shadow info echo "please input the password:" read passwd m=1 while [ $m -le $num ] do echo $passwd | /usr/bin/passwd --stdin $name$m m=`expr $m + 1` done
批量删除
#!/bin/sh echo "please input username:" read name echo "please input number:" read num sum=0 while [ $sum -lt $num ] do sum=`expr $sum + 1` /usr/sbin/userdel -r $name$sum done