linux 批量10个用户 id,shell脚本,批量创建10个系统帐号并设置密码为随机8位字符串。...

[[email protected] wyb]# cat user10.sh

#!/bin/bash

#批量创建10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串)。

>user.list

for user in `seq -w 10`

do

useradd wangyb$user

password=`echo $RANDOM|md5sum|cut -c 1-8`

echo $password|passwd wangyb$user --stdin

echo wangyb$user $password >> user.list

done

[[email protected] wyb]# bash user10.sh

Creating mailbox file: File exists

useradd: warning: the home directory already exists.

Not copying any file from skel directory into it.

Changing password for user wangyb01.

passwd: all authentication tokens updated successfully.

Creating mailbox file: File exists

useradd: warning: the home directory already exists.

Not copying any file from skel directory into it.

Changing password for user wangyb02.

passwd: all authentication tokens updated successfully.

Creating mailbox file: File exists

useradd: warning: the home directory already exists.

Not copying any file from skel directory into it.

Changing password for user wangyb03.

passwd: all authentication tokens updated successfully.

Creating mailbox file: File exists

useradd: warning: the home directory already exists.

Not copying any file from skel directory into it.

Changing password for user wangyb04.

passwd: all authentication tokens updated successfully.

Creating mailbox file: File exists

useradd: warning: the home directory already exists.

Not copying any file from skel directory into it.

Changing password for user wangyb05.

passwd: all authentication tokens updated successfully.

Creating mailbox file: File exists

useradd: warning: the home directory already exists.

Not copying any file from skel directory into it.

Changing password for user wangyb06.

passwd: all authentication tokens updated successfully.

Creating mailbox file: File exists

useradd: warning: the home directory already exists.

Not copying any file from skel directory into it.

Changing password for user wangyb07.

passwd: all authentication tokens updated successfully.

Creating mailbox file: File exists

useradd: warning: the home directory already exists.

Not copying any file from skel directory into it.

Changing password for user wangyb08.

passwd: all authentication tokens updated successfully.

Creating mailbox file: File exists

useradd: warning: the home directory already exists.

Not copying any file from skel directory into it.

Changing password for user wangyb09.

passwd: all authentication tokens updated successfully.

Creating mailbox file: File exists

useradd: warning: the home directory already exists.

Not copying any file from skel directory into it.

Changing password for user wangyb10.

passwd: all authentication tokens updated successfully.

[[email protected] wyb]# cat user.list

wangyb01 77950e07

wangyb02 ace3cfb1

wangyb03 2cd63081

wangyb04 0f891e3c

wangyb05 600bedd4

wangyb06 73d3dfdc

wangyb07 30740006

wangyb08 54cf685f

wangyb09 ee3f88af

wangyb10 b54d2555

[[email protected] wyb]# su wang01

su: user wang01 does not exist

[[email protected] wyb]# su wangyb01

[[email protected] wyb]$ su wangyb10

Password:

[[email protected] wyb]$

[[email protected] wyb]# cat deluser10.sh

#!/bin/bash

#批量删除10个系统帐号wangyb01-wangyb10并设置密码(密码为随机8位字符串)。

> user.list

for user in `seq -w 10`

do

userdel wangyb$user

done

[[email protected] wyb]# bash deluser10.sh

[[email protected] wyb]# su wangyb01

su: user wangyb01 does not exist

[[email protected] wyb]#

时间: 09-04

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
>