Results 1 to 4 of 4

Thread: User account creation shell script

  1. #1
    Member
    Join Date
    Jan 2010
    Posts
    65
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    5

    Default User account creation shell script

    Im new to scripting what i want to do is create 20 user accounts. I want the user account to be ex. user1 ..... user20. but the password can be auto generated; also for each user account created i want to send a text file to /home/admin/useraccounts folder with each username and password for each user ; separate text file for each user.

  2. #2
    Senior Member
    Join Date
    Jun 2007
    Location
    Hyderabad, AP, India
    Posts
    806
    Thanks
    44
    Thanked 55 Times in 48 Posts
    Rep Power
    13

    Default

    Code:
    #!/bin/bash
    #Author:Surendra Kumar Anne
    #Purpose:To automate user creation
    #Date/Time:29-01-2010.19:10
    mkdir -p /home/admin/useraccounts
    for (( i=0; i<=20; i++ ))
    do
    useradd user$i
    < /dev/urandom tr -dc A-Na-n1-9_ | head -c8 > /tmp/passwd.txt
    cat /tmp/passwd.txt | passwd --stdin user$i
    echo -e "Username:user$i" > /home/admin/useraccounts/user$i
    echo -e "password:" >> /home/admin/useraccounts/user$i
    cat /tmp/passwd.txt >> /home/admin/useraccounts/user$i
    done
    rm -rf /tmp/passwd.txt
    Note:When password generating i just created a password which will not contain o(small ooo), O(capital OO), 0(zero). This is to remove confusions for users.. some times user will get confusion when using these characters
    Last edited by kumarat9pm; 29th January 2010 at 06:34 PM.
    Thanks,
    Surendra Kumar Anne
    Linux: Fast, friendly, flexible and .... free!
    Support Open source.
    http://www.linuxnix.com

  3. The Following 3 Users Say Thank You to kumarat9pm For This Useful Post:

    duster (29th January 2010), jaysunn (29th January 2010), vamsi (4th February 2010)

  4. #3
    Member
    Join Date
    Jan 2010
    Posts
    65
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    5

    Default

    that worked perfectly. Thanks now i will need to understand the code...any book you recommend for shell scripting?

  5. #4
    Senior Member
    Join Date
    Jun 2007
    Location
    Hyderabad, AP, India
    Posts
    806
    Thanks
    44
    Thanked 55 Times in 48 Posts
    Rep Power
    13

    Default

    You can refer Nixcraft guide
    http://nixcraft.com/attachments/shel...lsst2_0_r9.zip
    or
    The Linux Documentation Project site
    BASH Programming - Introduction HOW-TO
    Thanks,
    Surendra Kumar Anne
    Linux: Fast, friendly, flexible and .... free!
    Support Open source.
    http://www.linuxnix.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Solved] How to create multiple user account?
    By droidwork in forum Shell scripting
    Replies: 14
    Last Post: 20th October 2010, 10:30 AM
  2. Replies: 4
    Last Post: 21st March 2009, 06:30 PM
  3. Replies: 1
    Last Post: 2nd March 2009, 04:02 PM
  4. Shell BIND NAMED Zone Creation Script
    By asim.mcp in forum Shell scripting
    Replies: 4
    Last Post: 13th February 2009, 04:51 PM
  5. mysql account creation
    By in forum Linux software
    Replies: 1
    Last Post: 28th January 2006, 11:17 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •