标签:shell
1、批量建20个账号,从user1,user2,user20;密码为user后跟五位随机字符
[root@nova shell]# cat Guseradd
#!/bin/bash
for i in {1..20}; do
x="user"
pass=$x$(tr -dc \~\`\!@#\$\%\^\&\*\(\)\-\_\+\=\|\\\?\/\.\>\,\<a-za-z0-9_ </dev/urandom|head -c 5|xargs) ##/dev/urandom 产生随机数#
useradd user${i}
echo $pass | passwd user${i} --stdin ##stdin表示从标准输入读取令牌##
echo "user${i} <=============> $pass" >> ./userlist.log
done
echo ‘Sucess,passwd is in userlist.log‘
2、批量删除user1,user2...user20这20个账号
#cat Guserdel
#!/bin/bash
for i in {1..20}; do
userdel -r user${i}
echo "user${i} is del" |tee -a userdel.log
done
echo "sucess,users is deleted"
3、挂载\\10.10.1.1\sd 共享文件夹,假定账户为user1,密码为p4ssword,
mkdir -p /mnt/sd
mount -t cifs //10.10.1.1/sd /mnt/sd -o user=user1,password=p4ssword
本文出自 “风起!云涌!” 博客,请务必保留此出处http://superzxh.blog.51cto.com/27819/1675194
标签:shell
原文地址:http://superzxh.blog.51cto.com/27819/1675194