Home  >  Article  >  System Tutorial  >  How to automatically create users in batches in Linux

How to automatically create users in batches in Linux

WBOY
WBOYforward
2023-12-28 20:11:31802browse
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.

在 Linux 中如何自动批量创建用户

Require

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 username

First, 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
...
Create user

After creating the file containing user information, use the newusers command to create the user.

# newusers users-list.txt
Check User Account

Finally you can confirm that the users have been created correctly by viewing them in the /etc/passwd file:

# tail /etc/passwd

在 Linux 中如何自动批量创建用户


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!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete