creating multiple users
Hi. I would like to create multiple users at one go. I read up on the command newusers and tried to use it. but the problem was, the created users could not login as they had no login profiles created in their home directories. I mean, the created user directories were blank. No bash profiles in them, nothing. So i suppose i could copy all these default files from a user created manually and start working or is there a better way?
In the first case, how can i copy the files to multiple directories? The home directories do not have anything common in their name except that they are all in the same directory. Thank you very much for your help. |
I think the useradd command will do what you want. Using the various command line options to do different things. See the manual page for more details.
|
no, the useradd command can add only one user at a time. And moreover the password has to specified in an encrypted form with the -p option. I want to create a whole batch of users (200+) at a go. When i use the newusers command for it with the syntax given in the man pages, i end up creating all the users, but none of them have login shells. It displays the shell in the etc/passwd file but when i try to login as any of the thus created users, it gives me an error saying that no login shell found. What could be the error here?
And abt the copying thing, i tried copying all the files (hidden and all) from a working user to one of these users' home directories but that didnt work either. So i guess I am now looking for some way to add hundreds of users at a time. I do not know much about scripting so i can't code them myself. Any help would be appreciated. Thanks again. |
Write a file containing the list of user names and other details (e.g. comment, shell, skeleton directory and so on).
Write a shell script which iterates over this list. For each line it should also call makepasswd with the --crypt-md5 or --crypt option as appropriate for your system, saving the unencrypted password in a file with the username, which is cut up and given to users by whatever means you do that. Make sure the permissions on this file are such that only the root user can read or write it! useradd should be called with the appropriate values and with the encrypted password value. As long as you user the shell-internal echo command (note this is "print" if you use ksh, "echo" if you use bash), the un-encrypted password will not be visible in the process list. I'm sure there are pre-written tools for this sort of thing, but it's good to know how to do it yourself. :) A very simple version might look like this. Only the username, group and name are provided in the lilst of user file, which is called "userdata": Code:
user1 users User One Code:
#!/bin/bash Make sure you run this program in a directory which is owned by root, else the owner of the directory might be able to remove, rename or otherwise mess with the user_passwords file. It's best done in root's home directory, and that is best set so only root can see inside it. I hope that helps. Also, please note that I have never actually done this operation myself (except just now as a test). I'm sure there are other ways to do it, and maybe a seasoned sysadmin will say my method is not good for some reason. Ho hum. :) |
thanks a lot. p.s. i don't care what any sysad says! btw, i was just experimenting and found another alternative. there's a chpasswd command to change passowrds in bulk and that can be used after creating users without passwords.
|
Quote:
|
All times are GMT -5. The time now is 02:09 PM. |