Search This Blog

Tuesday, January 20, 2009

Change user password in one line i.e in one go

echo passwd | passwd user --stdin


if you have many user, need to reset password , create a file (id) with all user names and --
for i in `cat id`
do
echo $i
echo 123789 | passwd $i --stdin
sleep 1
done

This will set password to 123789 for all the users lists in the file (id).

3 comments:

  1. eg_ a user named "vikas" is there
    Now to change its password You will use passwd command, which will prompt for new password as below

    $ passwd vikas
    New UNIX password:
    BAD PASSWORD: it is too simplistic/systematic
    Retype new UNIX password:
    passwd: all authentication tokens updated successfully.

    Now do this in one line
    $ echo ur_passwd | passwd user_name --stdin
    i.e
    echo 123654 | passwd vik_user --stdin

    Now script if you have many user, write them in a file.
    Read each user from file and reset their passwd.

    ReplyDelete