newusers
Create multiple user accounts from batch file
SYNOPSIS
newusers < batch_file
DESCRIPTION
The `newusers` command is a utility in Linux for creating multiple user accounts from information provided in a batch file. This is significantly more efficient than using the `useradd` command individually for each user, especially when setting up systems for educational institutions, businesses, or other scenarios involving a large number of new accounts.
The input file is expected to follow a specific format, typically with one user per line, containing colon-separated fields such as username, password (usually an encrypted placeholder like 'x' or '*'), user ID (UID), group ID (GID), GECOS information (full name, room number, etc.), home directory, and login shell. The `newusers` command then processes this file, creating the user accounts and setting the specified attributes accordingly. If the home directory specified in the input file does not exist, it will not be created automatically; you may need to use other utilities like `useradd -m` or write a script to create the home directories. Errors during the account creation process for one user will generally not halt the processing of other users in the input file, though it's important to check system logs or error messages for any failed attempts.
Note: Be extremely cautious when crafting the input file, as incorrect data can lead to undesirable or even insecure user configurations. Carefully review your file and test it on a non-production environment before deploying it widely.
CAVEATS
The command does not create home directories. The password in the input file is usually a placeholder. You will typically need to use other utilities (like `chpasswd`) or write a script to set actual passwords after the accounts are created. Care must be taken with UIDs, GIDs, and GECOS information to ensure consistency and security. Errors during user creation are not fatal for other users in the input file, requiring careful monitoring.
INPUT FILE FORMAT
The input file for `newusers` should contain one user entry per line. Each line should consist of colon-separated fields in the following order: username, password, UID, GID, GECOS, home directory, and login shell. The password field is often set to 'x' or '*' as a placeholder. Example:
`john:x:1001:1001:John Doe:/home/john:/bin/bash`
PASSWORD ENCRYPTION
The `newusers` command itself does not handle password encryption directly. The password field in the input file is typically a placeholder. A separate utility, such as `chpasswd`, is used to set real passwords for the newly created accounts after running `newusers`. It's strongly recommended to use a secure password generation and management strategy.
ERROR HANDLING
If an error occurs during the creation of a user account, `newusers` will continue processing the remaining users in the input file. You should carefully examine the system logs or error messages to identify and resolve any issues that arise during user creation. Proper logging and error handling are crucial when managing user accounts in batch.
HISTORY
The `newusers` command is part of the shadow-utils package, a collection of utilities designed for managing user accounts and security features on Linux systems. It was created to simplify the batch creation of users. The command has been available for many years and has become a standard tool for system administrators.