[CentOS] A full detailed add user script

Sun Feb 18 14:40:08 UTC 2007
Michael Watters <wattersm at liquidweb.com>

Dwi Suharto wrote:
> Anyone here have any sample script, using BASH, for adding user. The 
> script can define:
> - home directory
> - quota
> - create public_html folder
> - update shadow password (in replace to manually using passwd 
> particularly to related user)
>
> Thank you.
>
> Dwi Suharto
> Rumahweb's TSO
> http://www.rumahweb.com
>
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
No but it shouldn't take more than 10 minutes to write one.  All you 
would need is to run a script like this:

useradd foo
setquota foo 102000000 102000000 0 0 /home #this is 100GB
mkdir /home/foo/public_html
echo plain_pass | passwd --stdin foo

You can also have the script read command line arguments so you can 
specify the user name as an argument and read it using $1. 

Also, you shouldn't edit the shadow file directly, that's what the 
passwd command is for.