您的位置:首页 > 运维架构 > Linux

Centos下批量创建用户并且新建的用户可登录的方法

2017-10-05 13:44 417 查看
[root@localhost tmp]# touch username.txt 创建用户名文件

[root@localhost tmp]# vi username.txt




[root@localhost tmp]# touch serc.txt 创建密码文件,并且密码和用户名相同
[root@localhost tmp]# vi serc.txt



(要注意格式)

[root@localhost tmp]# vi aa.sh 创建执行的脚本




[root@localhost tmp]# ./aa.sh
bash: ./aa.sh: 权限不够

[root@localhost tmp]# chmod 777 aa.sh (解决权限不够的问题,要记得执行后删除aa.sh

[root@localhost tmp]# ./aa.sh
ok!!!




批量增加了六个用户,并且用户的初始密码与用户名相同

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~分割线~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

在《鸟哥的Linux私房菜》看到的一种批量创建用户的方法:

[root@localhost ~]# mkdir bin
[root@localhost ~]# cd /root/bin
[root@localhost bin]# vim useradd.sh



[root@localhost bin]# sh useradd.sh



[root@localhost bin]# id vbird1



[root@localhost bin]# su - vbird1 可以正常登录



从vbird1切换到vbird2,新建的用户密码都为passwd


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息