批量添加用户

来源:互联网 发布:网络精灵国语版 编辑:程序博客网 时间:2024/05/01 15:29
<!--[if gte mso 9]><![endif]-->

Newusers命令导入用户信息文件

格式:

[username]:[userpassword]:[UID]:[GID]:[usernote]:[userhome]:[shell]

首先用vi创建user.info文件

     可以在其写入

brother01::1001:3::/home/brother01:/bin/bash

brother02::1002:3::/home/brother02:/bin/bash

brother03::1003:3::/home/brother03:/bin/bash

brother04::1004:3::/home/brother04:/bin/bash

brother05::1005:3::/home/brother05:/bin/bash

brother06::1006:3::/home/brother06:/bin/bash

brother07::1007:3::/home/brother07:/bin/bash

brother08::1008:3::/home/brother08:/bin/bash

将其导入

[root@localhost home]# newusers <file1

则自动生成用户

可查看其文件

[root@localhost home]# tail -5 /etc/passwd

显示效果为

brother04:$1$fMPNXx5T$ILrPNrOxoEfqw4sQH7ozN/:1004:3::/home/brother04:/bin/bash

brother05:$1$fMPNXx5T$ILrPNrOxoEfqw4sQH7ozN/:1005:3::/home/brother05:/bin/bash

brother06:$1$fMPNXx5T$ILrPNrOxoEfqw4sQH7ozN/:1006:3::/home/brother06:/bin/bash

brother07:$1$fMPNXx5T$ILrPNrOxoEfqw4sQH7ozN/:1007:3::/home/brother07:/bin/bash

brother08:$1$fMPNXx5T$ILrPNrOxoEfqw4sQH7ozN/:1008:3::/home/brother08:/bin/bash

/home中可以看到将为其文件自动生成

[root@localhost home]# ls 

显示效果为

brother01  brother04  brother07  dir_2  file4  home      user.info  

brother02  brother05  brother08  dir4   file5  new_list  brother03  brother06