pass=$(perl -e 'print crypt($ARGV[0], "asdf1234")' $password)

for i in {01..02};do

    yes $pass | yppasswd $usname


I want to change the password of the users but when I run this script I have to give the server password every time because I am usingyppasswd command . But when I used passwd command the NIS files won't change.

  • What distribution are you using? – terdon Nov 9 '15 at 12:59

Use chpasswd command to change the password using script

root@SHW:cat password.list

root@SHW:chpasswd < password.list

Above example illustrate an example of given command to change password of users namely user1,user2,user3.

| improve this answer | |
  • the chpasswd is not Working $usname:$pass|chpasswd – Ann Nov 9 '15 at 12:33
  • 1
    @Ann "not working" doesn't tell us anything. You need to explain exactly how it fails. Is there an error message? No error but the password is unchanged? Some passwords changed but problems with the NIS? – terdon Nov 9 '15 at 12:35
  • changepwUser1.sh: line 9: EDSAD15001:asbTyBDRLWRmQ: command not found changepwUser1.sh: line 9: EDSAD15002:asbTyBDRLWRmQ: command not found this the error I am getting the list of the user is generating along with password when the script is running – Ann Nov 9 '15 at 12:36
  • @Ann and what are you running? We don't have access to yours scripts, please edit your question and show us what you did exactly. – terdon Nov 9 '15 at 13:01
  • Have you tried above script with your existing username/password pair ? – SHW Nov 10 '15 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.