Introduction | As a Linux system administrator, you sometimes have to add new user accounts to the system. For this purpose, the adduser command is often used. When it comes to the creation of multiple users, the adduser command can become quite boring and time-consuming. This short article aims to provide Linux system administrators with a simple and unattended way to create users in batches. The newusers command will help you create multiple users by getting information from pre-populated files. |
Privileges to access Linux computers.
Promise# - The given command needs to be run with root user privileges or using sudocommand
$ - The given command is run as a user with regular permissions
how to proceed Create a file containing usernameFirst, you need to create a file containing a list of usernames.
$ vi users-list.txt
In the file, one user per line, the following is the style:
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 ...
After creating the file containing user information, use the newusers command to create the user.
# newusers users-list.txt
Finally you can confirm that the users have been created correctly by viewing them in the /etc/passwd file:
# tail /etc/passwd
The above is the detailed content of How to automatically create users in batches in Linux. For more information, please follow other related articles on the PHP Chinese website!