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

How to automatically create users in batches in Linux

Dec 28, 2023 pm 08:11 PM
linux linux tutorial Red Hat linux system linux command linux certification red hat linux linux video

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!

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

deepseek web version entrance deepseek official website entrance deepseek web version entrance deepseek official website entrance Feb 19, 2025 pm 04:54 PM

deepseek web version entrance deepseek official website entrance

Android TV Box gets unofficial Ubuntu 24.04 upgrade Android TV Box gets unofficial Ubuntu 24.04 upgrade Sep 05, 2024 am 06:33 AM

Android TV Box gets unofficial Ubuntu 24.04 upgrade

How to install deepseek How to install deepseek Feb 19, 2025 pm 05:48 PM

How to install deepseek

BitPie Bitpie wallet app download address BitPie Bitpie wallet app download address Sep 10, 2024 pm 12:10 PM

BitPie Bitpie wallet app download address

BITGet official website installation (2025 beginner's guide) BITGet official website installation (2025 beginner's guide) Feb 21, 2025 pm 08:42 PM

BITGet official website installation (2025 beginner's guide)

Zabbix 3.4 Source code compilation installation Zabbix 3.4 Source code compilation installation Sep 04, 2024 am 07:32 AM

Zabbix 3.4 Source code compilation installation

Detailed explanation: Shell script variable judgment parameter command Detailed explanation: Shell script variable judgment parameter command Sep 02, 2024 pm 03:25 PM

Detailed explanation: Shell script variable judgment parameter command

Ouyi okx installation package is directly included Ouyi okx installation package is directly included Feb 21, 2025 pm 08:00 PM

Ouyi okx installation package is directly included

See all articles