Revision: 53607
                            
                                                            
                                    
                                        
Initial Code
                                    
                                    
                                                            
                                    
                                        
Initial URL
                                    
                                    
                                
                                                            
                                    
                                        
Initial Description
                                    
                                    
                                                            
                                    
                                        
Initial Title
                                    
                                    
                                                            
                                    
                                        
Initial Tags
                                    
                                    
                                                            
                                    
                                        
Initial Language
                                    
                                    
                                                    
                        at November 29, 2011 13:41 by jiewmeng
                            
                            Initial Code
#!/bin/bash echo "Creating user: $1" PASSWD=`makepasswd --char=8` echo "Password: $PASSWD" ENPASSWD=`mkpasswd $PASSWD` sudo useradd $1 -d "/var/www/$1" -g devs -m -p "$ENPASSWD" echo "Creating mysql user & database for $1" mysql -u root --password=km123 -e "CREATE DATABASE $1; CREATE USER $1 IDENTIFIED BY '$PASSWD'; GRANT ALL ON $1.* TO '$1'"
Initial URL
Initial Description
**Usage**
    > newuser.bash [username]
**What it does**
- Generates a random password with `makepasswd`
- Encrypts it with `mkpasswd` for use with useradd
- Adds the user
- Adds a MySQL Database for user
- Adds a MySQL User for user
- Grants all privileges to user to his/her database
**Sample Output**
    km@KM-VBox:~$ ./newuser.bash test1
    Creating user: test1
    Password: zV8MDMRh
    [sudo] password for km: 
    Creating mysql user & database for test1
[Short demo on Screenr (1min)](http://screenr.com/ghzs)
                                Initial Title
Create Linux User with Geneated Password and MySQL User
Initial Tags
mysql, linux, user
Initial Language
Bash