歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> SHELL編程 >> Shell應用:批量添加用戶

Shell應用:批量添加用戶

日期:2017/3/1 10:35:35   编辑:SHELL編程

事例

腳本代碼:

[plain]

  1. #/bin/bash
  2. // batch_add_user.sh
  3. users=`awk -F: '{print $1}' users.conf`
  4. home='/home/'
  5. for user in $users
  6. do
  7. password=`grep $user users.conf | awk -F: '{print $2}'`
  8. useradd -d ${home}${user} $user
  9. grep $user users.conf | chpasswd
  10. chage -d 0 $user
  11. done
配置文件:

[plain]

  1. linuxidc:www.linuxidc.com
Copyright © Linux教程網 All Rights Reserved