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

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.