简体   繁体   中英

linux bash shell: how to create user with username and password from file?

I'm clear about everything except how to set password using the script. Normally, I would write:

passwd username

And the terminal would prompt for password. How to read password from file instead?

You can use:

passwd --stdin username < filename

From passwd(1) :

--stdin This option is used to indicate that passwd should read the new password from standard input, which can be a pipe.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM