Script for automatically changing common user passwords in batches

Source: Internet
Author: User
The script for automatically changing passwords of common users in batches-Linux general technology-Linux technology and application information. The following is a detailed description. [I = s] This post was last edited by yanyongkg

Method 1:
CODE :#! /Bin/bash
# Automatically change the password of the common user to 123456

# The common users obtained here are usually correct. For example, if you specify the ID as a number smaller than 500 when creating a user, the user cannot be obtained.
# During the test, the ID of an nfsnobody user is 65534. The awk adds a/sbin/nologin judgment to filter out such users.
Userlist = $ (awk 'in in {FS = ":" };{ if ($3 >=500 & $7 !~ "/Sbin/nolo \
Gin ") printf $1" \ n "} '/etc/passwd)

For I in $ userlist
Do
Chpasswd <$ I: 123456"
Echo "The user $ I password is OK! "
Done

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.