- Introduction to UNIX Users and Groups
- The Users and Groups Module
- Creating a New User
- Editing an Existing User
- Deleting a User
- Creating a New Group
- Editing an Existing Group
- Deleting a Group
- Viewing Recent and Current Logins
- Reading Users' Email
- Creating Users from Batch Files
- Configuring the Users and Groups Module
- Before and After Commands
- Module Access Control
- Other Operating Systems
- Summary
4.11 Creating Users from Batch Files
Sometimes you may want to create a large number of users at once without having to go through the process of filling out the user creation form over and over again. You will often have the details of these users in a text file of some kind containing their usernames, passwords, and real names. Fortunately, Webmin has a feature that automates this task for you.
If you click on the Create, modify and delete users from batch file link above or below the list of existing users, a form will appear that allows you to upload a file containing the details of users to create, as shown in Figure 4.8. Your file must contain one line of text for each user that you want to create, and the format of each line must match the format shown on the batch file page.
Figure 4.8. The batch file execution form.
The exact file format depends on what information your system stores about each user, but on most systems each line must follow this format:
create:username:passwd:uid:gid:realname:homedir:shell:min:max:warn:inactive:expire
An example line to create a user with the user ID automatically assigned by Webmin would be:
create:jcameron:mysecret::3001:Jamie Cameron:/home/jcameron:/bin/bash:::::
As you can see, the line is made up of a series of fields, each separated by a colon (:). When creating a user, the first field must be the create field. The meanings of the other fields are shown in Table 4.1.
Once you have created a file containing the details of users to create, select it using either the Upload batch file or Local batch file fields, and click the Execute batch button. A page displaying each user created and any errors encountered will be displayed. The most common error is a missing field in one of the lines—each must have exactly the right number of fields, and even if a field is blank the colon separator next to it must still be included.
Table 4.1. Batch File Fields and Their Meanings
username |
The user's login name. This cannot be left blank. |
passwd |
The user's password. If this field is left blank, then no password will be needed for the user. If it contains just the letter x, then the user will be locked and no login allowed. |
uid |
User ID for the new user. This should be left blank, so Webmin can assign one automatically. |
gid |
ID of the user's primary group. This cannot be a group name, and cannot be left blank. If more than one GID is entered, the user will be added as a secondary member to all of those listed after the first one as well. |
realname |
The user's real name. Not mandatory, but should not be left blank. |
homedir |
A directory that is created with ownership assigned to the user. You can leave this blank if the module has been configured to assign home directories automatically. |
shell |
The user's login shell. This field cannot be left blank. |
min |
The number of days after the user is created or the password is last changed that the user must wait before changing it again. Can be left blank to allow changing as soon as the user likes. |
max |
The number of days after the user is created or the password is last changed that the password expires and must be changed again. If left blank, the password will never expire. |
warn |
The number of days before the password expiry date that the user will be warned at login that his password is about to expire. If left blank, the user will not know that his password has expired until it happens. |
inactive |
The number of days after the password expires that the entire account will be disabled, if the user has not chosen a new password. If left empty, the account will never expire. |
expire |
The date on which this account will expire. Unfortunately, you must enter this as a number of days since January 1, 1970! |