Users of the Linux system management, batch add users operating procedures

Author: North-South-North
from: League of Legends Community
Abstract: In Linux user management, users often add large quantities needed; if using useradd or adduser to add a large number of users, the system administrator's physical strength and endurance is a great challenge; fortunately there are large quantities of Linux users to add tools newusers, we can easily complete the high-volume users by adding newusers and chpasswd;
environment: Fedora 4.0 i386


Contents Index

First, read this file you need to master the basics of;
Second, why the need to add high-volume users;
Third, the user batch add process;

Fourth, the bulk add user instance;

V. Postscript;
VI, on the paper;
seven thanks;
Eight, reference documents;
nine related documents;


First, read this file you need to master the basics of;

"Linux user (user) and user groups (group) Management Overview,"
"user (user) and user groups (group) Profile Detailed"
"Linux users (User) inquiry chapter"
"Linux User Management Tool Introduction"
"Linux system control super authority "


Second, why the need to add high-volume users;

When do we only need to add large quantities of users? Sometimes we need to make dozens or more users perform the same or similar tasks on the host, such as we'd like to add a bunch of ftp user, ftp these users belong to the same group, but they are not allowed through the terminal or remote login server ; sometimes we may for teaching, for example, we have 50 students, and each student has a separate user name on the server, the system can log on, and can manage their own accounts or to complete some work in their own rights;


Third, the user batch add process;

Batch is introduced to add a user process in strict accordance with / etc files / passwd writing format written content newusers accomplished by adding users, and then import user password file to complete the process by batch updates chpasswd user password;


1, newusers bulk add user tools;

Its usage is very simple, with a file directly behind newusers; the same file format and / etc / passwd format;


Username 1: x: UID: GID: User Description: The user's home directory: used SHELL

For example:

win00:x:520:520::/home/win00:/sbin/nologin
win01:x:521:521::/home/win01:/sbin/nologin
......

It is worth mentioning about the type SHELL, SHELL all hosts on view, can be viewed by chsh;

[root@localhost beinan]# chsh --list
/bin/sh
/bin/bash
/sbin/nologin
/bin/ksh
/bin/tcsh
/bin/csh
/bin/zsh

Which in addition to / sbin / nologin, other types of SHELL can log into the system; nologin is mostly used SHELL virtual users, that is to say, although he is the system user, but he had no permission to log into the system; if you want to add this type of user , SHELL arranged to put his / sbin / nologin, such as the above example;

User name, UID, GID and the user's home directory is how it is, you can read the corresponding reference documentation;


2, chpasswd bulk update tool user password;

chpasswd tool is a tool bulk update the user password, the contents of a file is added to redirect / etc / shadow in;

chpasswd <File

But not the contents of the file there is no agreement, it must be written in the following format, and no blank lines;


Username: password

Username 1: 1 Password
User name 2: 2 password

Example:

win00: 123456
win01: 654321
... ...


Fourth, the bulk add user instance;


1. First, we create a user and password files;

We want to create a file that contains userfile.txt new users; the other is for the user to set a password userpwdfile.txt newly added;

[root@localhost ~]# touch userfile.txt
[root@localhost ~]# touch userpwdfile.txt

Then open the file with a text editor userfile.txt, add the following;

win00:x:520:520::/home/win00:/sbin/nologin
win01:x:521:521::/home/win01:/sbin/nologin
win02:x:522:522::/home/win02:/sbin/nologin
win03:x:523:523::/home/win03:/sbin/nologin
win04:x:524:524::/home/win04:/sbin/nologin
win05:x:525:525::/home/win05:/sbin/nologin
win06:x:526:526::/home/win06:/sbin/nologin
win07:x:527:527::/home/win07:/sbin/nologin
win08:x:528:528::/home/win08:/sbin/nologin
win09:x:529:529::/home/win09:/sbin/nologin

userfile.txt contents of the file format and / etc / passwd format is the same, must strictly follow the / etc / passwd format writing; the user can not be added above the log, but is fully capable for ftp login, but you have to open for local users have read and write permissions in the appropriate configuration file ftp server; if you want the top part of the user can log into the system, you can put SHELL similar altered, such as change / bin / bash;

Let us write the new user's password file userpwdfile.txt content; the user name of this file to the same userfile.txt user name; that is, we first added to the win00 win09 users, these users now want to update password; such as the following;

win00:123456
win01:654321
win02:123321
win03:qweewq
win04:google
win05:adadwc
win06:wsscee
win07:xxec32
win08:543wew
win09:3ce3wf


2, and batch add user newusers chpasswd completion;

[root@localhost ~]# newusers userfile.txt
[root@localhost ~]# chpasswd < userpwdfile.txt

So even if the addition is complete, and if you find that / etc / passwd can be found out in the user's password, you can map the following command to the / etc / shadow file name;

[root@localhost ~]# pwconv


V. Postscript;

Even if the user management is almost complete, so far, I've written six, although the quality is not too high, but also considered can be regarded as a more systematic; in the next few days, I want to write a written document management; Oh . . . Progress is slow, but still insisted; persevering, is not it?

Sixth, on paper;

This article is an example of adding large quantities of users, mainly explain the usage of newusers and chpasswd; tell the truth, these two tools is useful; As can be used in which, as I said before, you can use the virtual on ftp users can use the teaching;

This article does not technical content, not worth mentioning, but not write, feeling for a series of documents it has less content; or write it for good;

Seven, thanks;

Eight, reference documents;

Refer to man and Help;

Nine, related documents;

"Linux user (user) and user groups (group) Management Overview,"
"user (user) and user groups (group) Profile Detailed"
"Linux users (User) inquiry chapter"
"Linux User Management Tool Introduction"
"Linux system control super authority "

Reproduced in: https: //www.cnblogs.com/licheng/archive/2008/01/21/1047164.html

Guess you like

Origin blog.csdn.net/weixin_34026276/article/details/92630365