Don’t change your iPhone’s root password. Just don’t. If you do you will have a phone that reboots in an infinite loop. And yes there are many places online that say that you can do this but they are WRONG.
Hopefully this will save someone the hours that it cost me.
There is a way to do this which might work but I really don’t think it’s worth the chance of the infinite loop. If you still want to do it, don’t use passwd but edit the passwd file directly. If you don’t know what that means don’t do it.