Shell脚本批量创建用户
一切都是为了能更好的偷懒
- 准备写个简单的创建用户的shell脚本。
- 支持 create username passwd 就行了。
预计是给创建简单的测试用户用的,所以密码直接写在命令行上面。因此请不要用于生产环境等,创建完毕也要及时删除脚本。
#!/bin/bash # create user and specified it's password. # created by [email protected] 2014/5/7 if [ -z "$1" ] && [ -z "$1"]; then echo "User created failed." echo "Command need 2 parameters like-> ./createUser myUserName myUserPassword" else name=$1 pwd=$2 groupadd $name useradd -g $name $name echo $name:$pwd | chpasswd cp /etc/security/limits.conf /etc/security/limits.conf.bak.beforeAddUser$name echo "$name soft nproc 2047" >> /etc/security/limits.conf echo "$name hard nproc 16384" >> /etc/security/limits.conf echo "$name soft nofile 65535" >> /etc/security/limits.conf echo "$name hard nofile 65535" >> /etc/security/limits.conf fi
测试用户不注意就会出现资源不足的情况,所以索性直接更改了其最大进程连接数和最大允许打开文件数。
相关推荐
huha 2020-10-16
laisean 2020-11-11
大牛牛 2020-10-30
firefaith 2020-10-30
liguojia 2020-10-20
wangzhaotongalex 2020-10-20
以梦为马不负韶华 2020-10-20
JohnYork 2020-10-16
Julyth 2020-10-16
applecarelte 2020-10-16
laisean 2020-09-27
flycappuccino 2020-09-27
liguojia 2020-09-27
wangzhaotongalex 2020-09-22
流年浅滩 2020-10-23
liujianhua 2020-10-22
woaimeinuo 2020-10-21
tufeiax 2020-09-03
laisean 2020-09-01
vvu 2020-09-16
libao 2020-09-16
Yyqingmofeige 2020-08-18
zhushixia 2020-08-17