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

How to automatically create users in batches in Linux

WBOY
Release: 2023-12-28 20:11:31
forward
809 people have browsed it
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
Copy after login

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
...
Copy after login
Create user

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

# newusers users-list.txt
Copy after login
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
Copy after login

在 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!

source:linuxprobe.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template