NEWUSERS(8) System Management Commands NEWUSERS(8)
π NAME
newusers - update and create new users in batch
π Quick Reference
| Use Case | Command | Description |
| Create or update users from a file | newusers [file] | Reads a file (or stdin) and creates/updates users. Each line is a password record. |
| Create system accounts | newusers -r [file] | Creates system accounts with UID/GID in the system range (SYS_UID_MINβSYS_UID_MAX). |
| Apply changes in a chroot environment | newusers -R CHROOT_DIR [file] | Apply changes in the specified CHROOT_DIR directory, using configuration files from there. |
| Allow nonβstandard usernames | newusers --badname [file] | Allow names that do not conform to standards. |
π SYNOPSIS
newusers [options] [file]
π DESCRIPTION
The newusers command reads a file (or the standard input by default) and uses this information to update a set of existing users or to create new users. Each line is in the same format as the standard password file (see passwd(5)) with the exceptions explained below:
pw_name:pw_passwd:pw_uid:pw_gid:pw_gecos:pw_dir:pw_shell
- pw_name π€ β This is the name of the user. It can be the name of a new user or an existing user (or created before by newusers). In case of an existing user, the user's information will be changed, otherwise a new user will be created.
- pw_passwd π β This field will be encrypted and used as the new value of the encrypted password.
- pw_uid π β This field defines the UID. If empty, a new unused UID is defined automatically. If a number, that number is used. If the name of an existing user, that user's UID is used. If the UID of an existing user is changed, the file ownership of the user's files must be fixed manually.
- pw_gid π₯ β This field defines the primary group ID. If it contains the name of an existing group, that group's GID is used. If a number, that number is used (if no group exists with that GID, a new group is created with that GID and the user's name). If empty, a new group is created with the user's name and a GID automatically defined. If it contains the name of a nonexistent group, a new group is created with that name and a GID automatically defined.
- pw_gecos π β This field is copied into the GECOS field of the user.
- pw_dir π β This field defines the home directory. If the directory does not exist, it is created with ownership set to the user and its primary group. If the home directory of an existing user is changed, newusers does not move or copy the content of the old directory.
- pw_shell π₯οΈ β This field defines the shell of the user. No checks are performed.
newusers first tries to create or change all the specified users, then writes these changes to the user or group databases. If an error occurs (except in the final writes), no changes are committed. During this first pass, users are created with a locked password (and passwords are not changed for existing users). A second pass updates passwords using PAM. Failures to update a password are reported but do not stop other updates. This command is intended for large system environments where many accounts are updated at once.
βοΈ OPTIONS
The options which apply to the newusers command are:
πΉ --badname
Allow names that do not conform to standards.
πΉ -h, --help
Display help message and exit.
πΉ -r, --system
Create a system account. System users will be created with no aging information in /etc/shadow, and their numeric identifiers are chosen in the SYS_UID_MINβSYS_UID_MAX range (defined in login.defs) instead of UID_MINβUID_MAX (and their GID counterparts for the creation of groups).
πΉ -R, --root CHROOT_DIR
Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory.
β οΈ CAVEATS
The input file must be protected since it contains unencrypted passwords.
π§ CONFIGURATION
The following configuration variables in /etc/login.defs change the behavior of this tool:
- GID_MAX (number), GID_MIN (number) β Range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers. Default: GID_MIN = 1000, GID_MAX = 60000.
- HOME_MODE (number) β The mode for new home directories. If not specified, the UMASK is used to create the mode. useradd and newusers use this to set the mode of the home directory they create.
- MAX_MEMBERS_PER_GROUP (number) β Maximum members per group entry. When the maximum is reached, a new group entry (line) is started in /etc/group (with the same name, same password, and same GID). Default: 0 (no limit). Note: split groups may not be supported by all tools (even in the Shadow toolsuite).
- PASS_MAX_DAYS (number) β The maximum number of days a password may be used. If older, a password change will be forced. If not specified, -1 (no restriction).
- PASS_MIN_DAYS (number) β The minimum number of days allowed between password changes. If not specified, -1 (no restriction).
- PASS_WARN_AGE (number) β The number of days warning given before a password expires. Zero means warning only on the day of expiration, negative means no warning. If not specified, no warning.
- SUB_GID_MIN (number), SUB_GID_MAX (number), SUB_GID_COUNT (number) β If /etc/subuid exists, the commands useradd and newusers (unless the user already has subordinate group IDs) allocate SUB_GID_COUNT unused group IDs from the range SUB_GID_MIN to SUB_GID_MAX for each new user. Defaults: 100000, 600100000, 65536.
- SUB_UID_MIN (number), SUB_UID_MAX (number), SUB_UID_COUNT (number) β If /etc/subuid exists, the commands useradd and newusers (unless the user already has subordinate user IDs) allocate SUB_UID_COUNT unused user IDs from the range SUB_UID_MIN to SUB_UID_MAX for each new user. Defaults: 100000, 600100000, 65536.
- SYS_GID_MAX (number), SYS_GID_MIN (number) β Range of group IDs used for the creation of system groups by useradd, groupadd, or newusers. Default: SYS_GID_MIN = 101, SYS_GID_MAX = GID_MIN - 1.
- SYS_UID_MAX (number), SYS_UID_MIN (number) β Range of user IDs used for the creation of system users by useradd or newusers. Default: SYS_UID_MIN = 101, SYS_UID_MAX = UID_MIN - 1.
- UID_MAX (number), UID_MIN (number) β Range of user IDs used for the creation of regular users by useradd or newusers. Default: UID_MIN = 1000, UID_MAX = 60000.
- UMASK (number) β The file mode creation mask is initialized to this value. If not specified, the mask will be initialized to 022. useradd and newusers use this mask to set the mode of the home directory they create if HOME_MODE is not set. It is also used by pam_umask as the default umask value.
π FILES
/etc/passwd β User account information.
/etc/shadow β Secure user account information.
/etc/group β Group account information.
/etc/gshadow β Secure group account information.
/etc/login.defs β Shadow password suite configuration.
/etc/pam.d/newusers β PAM configuration for newusers.
/etc/subgid β Per user subordinate group IDs.
/etc/subuid β Per user subordinate user IDs.
π SEE ALSO
login.defs(5), passwd(1), subgid(5), subuid(5), useradd(8).