Change passwords without interactive prompt in Linux

RHEL:

echo password | sudo passwd --stdin username
Debian/Ubuntu:
echo "username:password" | sudo chpasswd