Changing an AIX password via script?

后端 未结 13 1882
無奈伤痛
無奈伤痛 2020-12-23 16:43

I am trying to change a password of a user via script. I cannot use sudo as there is a feature that requires the user to change the password again if another user changes th

13条回答
  •  时光取名叫无心
    2020-12-23 17:24

    You need echo -e for the newline characters to take affect

    you wrote

    echo "oldpassword\nnewpasswd123\nnewpasswd123" | passwd user
    

    you should try

    echo -e "oldpassword\nnewpasswd123\nnewpasswd123" | passwd user
    

    more than likely, you will not need the oldpassword\n portion of that command, you should just need the two new passwords. Don't forget to use single quotes around exclamation points!

    echo -e "new"'!'"passwd123\nnew"'!'"passwd123" | passwd user
    

提交回复
热议问题