LinuxCommandLibrary

newusers

Create multiple user accounts from batch file

SYNOPSIS

newusers [OPTIONS] USER_DEFINITION_FILE

PARAMETERS

-S, --stdin
    Reads user definitions from standard input instead of a specified file. Each line should contain the data for one user according to the expected format.

DESCRIPTION

The newusers command is part of the shadow-utils suite, designed for creating multiple user accounts in a batch-processing manner. Instead of interactively adding one user at a time with tools like useradd, newusers reads user definitions from a specified file or standard input. Each line in the input file typically represents a new user, with fields like username, password (often encrypted), UID, GID, comment, home directory, and shell, separated by colons. This utility is particularly useful for system administrators who need to provision many user accounts simultaneously, such as in educational institutions or large enterprise environments. It automates the process of adding entries to /etc/passwd, /etc/shadow, /etc/group, and /etc/gshadow, as well as creating home directories for new users.

CAVEATS

The newusers command requires root privileges to execute successfully.
The input file format is crucial; incorrect formatting can lead to errors or unexpected user configurations. Passwords in the input file are typically expected to be already encrypted (e.g., using openssl passwd, mkpasswd, or similar methods) to avoid storing plain-text passwords directly. While powerful for batch operations, it offers less granularity and interactivity than useradd for individual user management.

INPUT FILE FORMAT

The USER_DEFINITION_FILE or standard input typically expects each line to contain colon-separated fields representing a user. The common fields, in order, are: username:encrypted_password:UID:GID:comment:home_directory:shell. For example, a line might look like: johndoe:encrypted_hash_here:1001:100:John Doe,,,:/home/johndoe:/bin/bash. The exact number and order of fields, as well as the expected format for fields like the comment, can vary slightly depending on the system's configuration and the specific version of newusers. It is essential to consult your system's man page (e.g., man newusers) for the precise format expected.

HISTORY

newusers is a long-standing component of the shadow-utils package, which provides utilities for managing user and group accounts and their respective password files (/etc/passwd, /etc/shadow, /etc/group, /etc/gshadow). Its design emphasizes batch processing, making it a valuable tool in environments requiring bulk account provisioning. While other tools and configuration management systems have emerged, newusers remains a direct and efficient way to create multiple accounts from a structured data source.

SEE ALSO

useradd(8), groupadd(8), usermod(8), userdel(8), passwd(1), group(5), passwd(5), shadow(5), pwconv(8), grpconv(8)

Copied to clipboard