Linux/centos shell script non-interactive password change

Source: Internet
Author: User
Tags stdin

Today when writing a shell script to find the need to set the user's password, and the setting of the password is interactive, so in the script is obviously not very good, so the Internet to find information, found the following two non-interactive set of password methods:


1. Using CHPASSWD

CHPASSWD is actually through the user input ' user name: password ' To change a set of user's password, or a batch password can be modified tool, the specific usage see CHPASSWD usage, here only to do a simple introduction

Format: # echo User name: password | chpasswd


For example, to add a Doiido account, the password is 123456, the instructions are as follows

# echo doiido:123456 | chpasswd

2. Using passwd and--stdin combination

passwd default is to use the terminal as the standard input, and--stdin means that you can use any file to do standard input, these two mates can directly modify the password

Format: # echo ' Password ' | passwd--stdin User Name


Or add a Doiido account, the password is 123456, the instructions are as follows

# echo ' 123456 ' | passwd--stdin Doiido


This allows you to modify the password in non-interactive mode, but it is not supported for some embedded Linux, and can be implemented using export.


This article from "Doiido" blog, reproduced please contact the author!

Linux/centos shell script non-interactive password change

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.