Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add users in batch under Linux

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to add users in batches under Linux", the content is simple and clear, and I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to add users in bulk under Linux".

Sometimes it is necessary to have dozens or more users perform the same or similar tasks on the host, such as adding a bunch of ftp users who belong to the same group, but are not allowed to log in to the server through terminals or remotely, which means adding users in bulk.

(1) first edit a text user file.

Each column is written in the format of the / etc/passwd password file. Note that each user's user name, UID, and host directory can not be the same, in which the password field can be left blank or enter the x number. A sample file, user.txt, contains the following:

User001::600:100:user:/home/user001:/bin/bashuser002::601:100:user:/home/user002:/bin/bashuser003::602:100:user:/home/user003:/bin/bashuser004::603:100:user:/home/user004:/bin/bashuser005::604:100:user:/home/user005:/bin/bashuser006::605:100:user:/home/user006:/bin/bash (2) executes the command / usr/sbin/newusers as root Import data from the newly created user file user.txt, and create a user: # newusers

You can then execute the command vipw or vi / etc/passwd to check that the / etc/passwd file has data for these users and that the user's host directory has been created.

(3) execute command / usr/sbin/pwunconv.

Decode the shadow password generated by / etc/shadow, then write back to / etc/passwd, and delete the shadow password field of / etc/shadow. This is to facilitate the next step of password conversion, that is, to cancel the shadow password function first.

# pwunconv (4) Edit the password comparison file for each user.

The sample file passwd.txt is as follows:

User001: password user002: password user003: password user004: password user005: password user006: password (5) execute command / usr/sbin/chpasswd as root.

Create a user password, and chpasswd writes the password encoded by the / usr/bin/passwd command to the password field of / etc/passwd.

# chpasswd (6) determines that the password is encoded into the password field of / etc/passwd.

Execute the command / usr/sbin/pwconv to encode the password as shadow password and write the result to / etc/shadow.

# pwconv

This completes the creation of a large number of users, and then you can go to / home to check that the permission settings for these user host directories are correct, and log in to verify that the user password is correct.

The above is all the content of the article "how to add users in batch under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report