Page 2 of 2 FirstFirst 1 2
Results 11 to 15 of 15

Thread: How to create multiple user account?

  1. #11
    Junior Member
    Join Date
    Jul 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default Creating multiple users in Suse Linux Enterprise Server 9

    Task 1 – Automating account creation by using shell scripts.

    You have been asked by your boss to set up 100 user accounts for your SLES9 Linux server. Each user account should have the following details:

    Login name: userxx
    Password: p@Ssxx
    UID: 1900+xx
    GID: 747 (name of group is IMFDelegates)
    Informational name: “Secret Agent xx
    Home directory: /home/agentxx
    Login shell: /bin/sh

    For example, the first user will have the following details:
    Login name: user00
    Password: p@Ss00
    UID: 1900
    GID: 747
    Informational name: “Secret Agent 00”
    Home directory: /home/agent00
    Login shell: /bin/sh

    And for example, the last user will have the following details:
    Login name: user99
    Password: p@Ss99
    UID: 1999
    GID: 747
    Informational name: “Secret Agent 99”
    Home directory: /home/agent99
    Login shell: /bin/sh

    Notify your lecturer once you have successfully created the 100 user accounts. You will then be required to demonstrate the successful login of some randomly selected accounts.

    Note: You will need to create a shell script to automate this task. You can make use of the groupadd and useradd scripts inside your shell script. You can also use the mkpass command to create the encrypted passwords.


    Anyone can help me with this??Thanks

  2. #12
    Junior Member
    Join Date
    Feb 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default how to create multiple users in Fedora or RedHat

    This example Written by Mahesh and Sathish on 23-02-2008 at Narasaraopet, will explain how to create multiple users using shell script.

    ####### file name : test.sh ##########
    #author : mahesh & sathish
    #date : 23-02-2008
    #NARASARAOPET

    uid="user"
    i=1

    #modify 50 to user required number and "student" to your choice group
    number_of_users=50
    mygroup="student"

    groupadd $mygroup
    while [ $i -le $number_of_users ]
    do
    useradd -g $mygroup $uid$i
    sh pwd $uid$i
    i=`expr $i + 1`
    done

    ###### end of test.sh ########

    #create one more file with the name pwd and give execute permissions


    ####### file name : pwd ##########
    #author : mahesh & sathish
    #date : 23-02-2008
    #NARASARAOPET

    passwd --stdin $1 <<end
    $1123
    $1123
    end
    ##########end of pwd ############

    #the above 2 programs creates 50 users as follows
    #first user login-id : user1
    #first user password : user1123
    # ....
    # ....
    #50th user login-id : user50
    #50th user password : user50123

    #run the first program i.e test.sh ex: ./test.sh (give chmod +x test.sh)

  3. #13
    Junior Member
    Join Date
    Oct 2010
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    I actually found a need for this last script, but when I put it to use I get: passwd: Authentication token manipulation error

    Currently using Fedora 10...
    What changes do I need to make to this last script to get it to work?

    Thanks in advance

  4. #14
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,374
    Thanks
    17
    Thanked 754 Times in 496 Posts
    Rep Power
    10

    Default

    Should be as follows:
    Code:
    #!/bin/bash
    user="$1"
    pass="$2"
    echo "$pass" | passwd --stdin "$user"
    Run it as follows
    Code:
    ./script.sh username password
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  5. The Following User Says Thank You to nixcraft For This Useful Post:

    StoneSting (20th October 2010)

  6. #15
    Junior Member
    Join Date
    Oct 2010
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Thank you very much for your help, what I ended up doing was using the second argument like you suggest, but a bit different...
    From the first script:
    sh pwd $uid$i
    changed to...
    sh pwd $uid$i 123

    and in the second script:
    passwd --stdin $1 <<end
    $1123
    $1123
    changed to...
    passwd --stdin $1 <<end
    $1$2
    $1$2

    This worked perfectly, with the only error coming back was that the password was too simplistic, but the employees will be told to change their passwords at first log in anyway, so no biggie.

    Thanks again!

Page 2 of 2 FirstFirst 1 2

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to create Multiple directories at once?
    By eawedat in forum Shell scripting
    Replies: 2
    Last Post: 15th March 2010, 08:21 PM
  2. Create new user account in Ubuntu Linux from command line
    By sweta in forum Getting started tutorials
    Replies: 3
    Last Post: 7th February 2010, 12:15 PM
  3. Apache Create FTP File Uploading Account
    By fadu in forum Web servers
    Replies: 2
    Last Post: 4th July 2009, 11:30 AM
  4. Replies: 1
    Last Post: 2nd March 2009, 04:02 PM
  5. Replies: 0
    Last Post: 20th December 2006, 02:01 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41