buser 发表于 2018-8-25 12:19:25

shell常用脚本

# cat creat_user.sh1  
#!/bin/sh
  
[ ! -d /chbo/ ]&& mkdir -p /chbo/
  
[ -f /chbo/passwd ]&& rm -f /chbo/passwd
  
for i in `seq -w 1 10`
  
do
  
password=`openssl rand -base64 6`
  
useradd chbo$i && echo $password |passwd --stdin chbo$i
  
echo "chbo$i$password" >>/chbo/passwd
  
done
  
# sh creat_user.sh1
  
Changing password for user chbo01.
  
passwd: all authentication tokens updated successfully.
  
Changing password for user chbo02.
  
passwd: all authentication tokens updated successfully.
  
Changing password for user chbo03.
  
passwd: all authentication tokens updated successfully.
  
Changing password for user chbo04.
  
passwd: all authentication tokens updated successfully.
  
Changing password for user chbo05.
  
passwd: all authentication tokens updated successfully.
  
Changing password for user chbo06.
  
passwd: all authentication tokens updated successfully.
  
Changing password for user chbo07.
  
passwd: all authentication tokens updated successfully.
  
Changing password for user chbo08.
  
passwd: all authentication tokens updated successfully.
  
Changing password for user chbo09.
  
passwd: all authentication tokens updated successfully.
  
Changing password for user chbo10.
  
passwd: all authentication tokens updated successfully.
  
# cat /chbo/passwd
  
chbo01Llkl7shd
  
chbo0229/JqICq
  
chbo037/0puAlT
  
chbo04MR6mDzqE
  
chbo05hMureKFp
  
chbo06WpQar93p
  
chbo07u4v0Dx+3
  
chbo08OY5FBbgy
  
chbo09JvCGq32D
  
chbo108BDfbxvT
  
# su - chbo01
  
$ su - chbo07
  
Password:
  
$ logout
  
$ logout
  
#


页: [1]
查看完整版本: shell常用脚本