Using the passwd command from within a shell script

前端 未结 13 999
遥遥无期
遥遥无期 2020-11-28 04:20

I\'m writing a shell script to automatically add a new user and update their password. I don\'t know how to get passwd to read from the shell script instead of interactively

13条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 04:47

    I stumbled upon the same problem and for some reason the --stdin option was not available on the version of passwd I was using (shipped in Ubuntu 14.04).

    If any of you happen to experience the same issue, you can work it around as I did, by using the chpasswd command like this:

    echo ":" | chpasswd
    

提交回复
热议问题