Following is the script for the user who want to change user password using bash script

#!/bin/sh -x
FROOT=`id | grep "uid=" | gawk '{print $1}' | cut -d "(" -f1 | sed 's/uid=//g'`
if [ $FROOT -ne 0 ]
		echo "Please run the script as a root user"
		echo "Enter username to change the password"
		read usr
		echo "Enter password you want to assign to the user"
		read pass
		(sleep 2; echo $pass; sleep 2; echo $pass) | passwd $usr
Changing user password in Linux via shell script

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recommend on Google