Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement non-interactive password modification in Shell script

Shulou Source: shulou.com Published: 2022-06-03 09:21:02 09月27日 Update

This article introduces the knowledge about "how to implement non-interactive password modification in Shell script". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

1: Use chpasswd

chpasswd is actually a user input 'username: password' to change the password of a group of users, or a tool that can change passwords in batches, specific usage see chpasswd usage, here only a simple introduction

Format: # echo Username: Password| chpasswd

Examples:

Add a doiido account with password 123456

The code is as follows:

# echo doiido:123456 | chpasswd

2: Use passwd and--stdin combination

passwd defaults to using terminal as standard input, while--stdin means that any file can be used as standard input. These two combinations can directly modify passwords.

Format: # echo 'password'| passwd --stdin username

Examples:

Add a doiido account with password 123456

The code is as follows:

# echo '123456'| passwd --stdin doiido

"How to implement Shell script non-interactive password change" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Tags: Password user name input interaction script Central Africa Code content instance more Standard format knowledge account practical learned next two Dilemma Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Redmi Xiaomi Apple Linux