Change system password from script – Linux

You can change the user password from a script like this:

echo "username:password" | chpasswd

Thus, you can create a new user and change his password in one command via a script:

useradd pingmonitor -m && echo "pingmonitor:newpassword" | chpasswd