批量创建用户和设置密码

本环境为centos suse默认没有newusers命令

(1) 首先创建用户名文件和密码文件
# touch user_name passwd
active:/srv # cat passwd
win00:123456
win01:123456

active:/srv # cat user_name
win00:x:520:520::/home/win00:/bin/bash
win01:x:521:521::/home/win01:/bin/bash

(2) 然后执行命令导入用户名和密码
active:/srv #   newusers user_name
active:/srv #   chpasswd <passwd

(3) 查看是否生成了相关的用户和密码
active:/srv #  tail -2  /etc/passwd  
win00:x:520:520::/home/win00:/bin/bash
win01:x:521:521::/home/win01:/bin/bash

active:/srv #  tail -2 /etc/shadow
win00:$1$nkhOl5As$1DRRv3Ho.JS43ZaNqpuqb0:15296:0:99999:7:::
win01:$1$nkhOl5As$1DRRv3Ho.JS43ZaNqpuqb0:15296:0:99999:7:::

(4) 用户登录验证
login as: win01
[email protected]'s password:
-bash-3.2$

你可能感兴趣的:(linux,职场,休闲,批量创建用户名和密码)