Find the answer to your Linux question:
Results 1 to 3 of 3
hi. i have a small bash script who read for example a file .txt with user name and make the user and set even a password. Code: #!/bin/sh for i ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    10

    create user script from file

    hi.
    i have a small bash script who read for example a file .txt with user name and make the user and set even a password.
    Code:
    #!/bin/sh
    for i in `more userlist.txt `
    do
    echo $i
    echo $i”123″ | passwd –stdin “$i”
    echo; echo “User $username’s password changed!”
    done
    the problem is that now for each user i must set a diferent UID and group.I will have direfernt files for example :
    user.txt UID.txt group.txt

    the file format is like this :
    user1
    user2
    ....


    Thank you for help.

  2. #2
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    You'll need to create the user (useradd) before you can set the password, and by default Linux will give each user a different uid and gid anyway. If you really want to specify the uid and gid, you'd be better having a single file with the three values for each user on a line (eg "user1 501 500"), then you can read the file line by line in a while loop and do what you have to really easily.

  3. #3
    Just Joined!
    Join Date
    Oct 2007
    Posts
    10
    i will try it
    thx

Posting Permissions

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