May
27
Posted on 27-05-2008
Filed Under (Linux commands) by Arun Bagul

Introduction –

This is the simple way to change password of user on Unix/Linux system non interactively! This script is really helpful for updating password in bulk or adding new users and setting  there password in bulk. Another method is to expect tool please refer article on expect!!

Let’s see the script now –

root@arun:~# cat /script/mypasswd.sh
#! /bin/bash

if [ $# -eq 2 ]; then
echo “Script to change password non-interactively”
echo “——————————————-”
else
echo ” * Usage: mypasswd.sh username   password”
exit 1
fi
passwd  $1<<ARUN
$2
$2
<<ARUN
root@arun:~#

How to use it ?

root@arun:~# ./mypasswd.sh
* Usage: mypasswd.sh username   password
root@arun:~#

root@arun:~# ./mypasswd.sh  myuser   mypwd
Script to change password non-interactively
——————————————-
Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
root@arun:~#
Thank you,
Arun Bagul

Similar Posts:

Be Sociable, Share!
(0) Comments    Read More   
Post a Comment
Name:
Email:
Website:
Comments:


www.flickr.com
arunbagul's photos More of arunbagul's photos
Get Adobe Flash player
-->