3.2 KiB
Simple way for unattended bulk user creation in Linux
Contents
Introduction
As a Linux system administrator, you will sometimes have to add new user account to your system. To do so, adduser
command is often used. When it comes to multiple users' creation, adduser
command may become boring and time-consuming. This short article intends to provide the Linux system administrator with a simple and unattended way for bulk user creation. The newusers
command will help you to create multiple users by getting their info from a prefilled file.
Requirements
Privileged access to your Linux machine
Conventions
- requires given command to be executed with root privileges either directly as a root user or by use of sudo
command
$ - given command to be executed as a regular non-privileged user
How to proceed
Create a file containing the usernames
In this initial step, you need to create a file that will contain the list of the usernames that are to be created.
$ vi users-list.txt
Put in your file, one user info per line, following the pattern below:
Username:Password:User ID:Group ID:User Info:Home Directory:Default Shell
Username:Password:User ID:Group ID:User Info:Home Directory:Default Shell
Username:Password:User ID:Group ID:User Info:Home Directory:Default Shell
...
Create users
After having created the previous file with predefined users info, use newusers
command to create users.
# newusers users-list.txt
Check user accounts
Finally you can confirm that the users were created correctly, by looking for their presence in the /etc/passwd
file:
# tail /etc/passwd
via: https://linuxconfig.org/simple-way-for-unattended-bulk-user-creation-in-linux
作者:Essodjolo Kahanam 译者:译者ID 校对:校对者ID