newusers command is a Linux utility that allows the creation of multiple user accounts simultaneously. It reads a file that contains a list of usernames, passwords, and other user account information, and creates the user accounts according to the specifications provided in the file. This is particularly useful in situations where a large number of user accounts need to be created in a short amount of time, such as in educational institutions or companies.
The syntax for the
newusers command is as follows:
newusers [options] <filename>
options argument is optional and can be used to modify the behavior of the command. The
<filename> argument is required and should contain a list of user account information in the following format:
Each line in the file represents a new user account to be created. The fields in the line are separated by colons (
:). The fields are defined as follows:
username: The name of the user account.
password: The encrypted password for the user account. If this field is empty, the user account will be created with no password.
UID: The user ID for the user account. If this field is empty, the next available UID will be assigned.
GID: The group ID for the user account. If this field is empty, the default group for the user will be used.
gecos: The GECOS field for the user account. This field can contain any additional information about the user.
home_dir: The home directory for the user account. If this field is empty, the default home directory will be used.
shell: The login shell for the user account. If this field is empty, the default shell will be used.
Create multiple user accounts from a file:
$ cat users.txt user1:password1::::: user2:password2::::: user3:password3::::: $ newusers users.txt
Create a user account with a specific UID and GID:
$ echo "user4:password4:1001:1001::::" > users.txt $ newusers users.txt
The available options for the
newusers command are as follows:
||Display help information and exit.|
||Display version information and exit.|
||Specify the starting UID for the first user in the file. Subsequent users will be assigned the next available UID.|
||Specify the starting GID for the first user in the file. Subsequent users will be assigned the same GID.|
||Create system accounts.|
||Specify the GECOS field for the user accounts.|
||Use default values for any fields that are not specified in the file.|
||Do not create a group with the same name as the user account.|
||Specify an alternate root directory for the home directories of the user accounts.|
- If the
newuserscommand fails to create any user accounts, check the syntax of the input file to ensure that it is correct.
- If the
passwordfield is left blank, the user account will be created with no password. This may pose a security risk, so it is recommended to set a password for each user account.
- If the
UIDfield is left blank, the next available UID will be assigned. However, if a specific UID is required, it should be specified in the input file to avoid conflicts with existing user accounts.
newuserscommand requires root privileges to run.
- The input file should be created with a text editor and saved as a plain text file.
- Usernames should be unique and not already exist on the system.