一切都是为了能更好的偷懒
- 准备写个简单的创建用户的shell脚本。
- 支持 create username passwd 就行了。
预计是给创建简单的测试用户用的,所以密码直接写在命令行上面。因此请不要用于生产环境等,创建完毕也要及时删除脚本。
#!/bin/bash # create user and specified it's password. # created by ifuteng@gmail.com 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
测试用户不注意就会出现资源不足的情况,所以索性直接更改了其最大进程连接数和最大允许打开文件数。