Newusers and chpasswd usage

Source: Internet
Author: User
The usage of newusers and chpasswd-Linux Enterprise Application-Linux server application information. The following is a detailed description. 1. Why do users need to be added in large batches;

When do we need to add a large number of users? Sometimes we need to have dozens or more users perform the same or similar tasks on the host. For example, if we want to add a bunch of ftp users at the same time, these ftp users belong to the same group, but they are not allowed to log on to the server through a terminal or remote connection. Sometimes we may want to teach. For example, we have 50 students, and each student has an independent user name on the server and can log on to the system, it can also manage its own accounts or complete some jobs with its own permissions;

2. Batch user addition Process;

The process of adding users in batch is to import a file written in strict accordance with the/etc/passwd format through newusers to add users, then, import the user password file through chpasswd to complete the process of batch updating user passwords;

1. newusers tools for adding users in batches;

The usage is simple. newusers is followed by a file directly. The file format is the same as that of/etc/passwd;

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

Example:

Win00: x: 520: 520:/home/win00:/sbin/nologin

Win01: x: 521: 521:/home/win01:/sbin/nologin

......

It is worth mentioning that for SHELL types, you can view all the shells on the host through chsh;

[Root @ localhost beinan] # chsh -- list

/Bin/sh

/Bin/bash

/Sbin/nologin

/Bin/ksh

/Bin/tcsh

/Bin/csh

/Bin/zsh

In addition to/sbin/nologin, other types of shells can log on to the system. Most of nologin is the SHELL used by virtual users. That is to say, although he is a system user, he has no permission to log on to the system; if you want to add such users, set the SHELL to/sbin/nologin, as shown in the preceding example;

For details about the username, UID, GID, and user's home directory, read the relevant reference documents;

2. chpasswd: Batch update of User Password tools;

The chpasswd tool is a tool used to update user passwords in batches. It is used to add the content of a file to/etc/shadow;

Chpasswd <File

However, the content of the file is not without conventions. It must be written in the following format and cannot be empty;

Username: Password

Username 1: Password 1

Username 2: Password 2

Example:

Win 00: 123456

Win01: 654321

......
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.