Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 03-02-2005, 09:03 PM   #1
Registered: Apr 2004
Distribution: Centos, Fedora
Posts: 125

Rep: Reputation: 17
Question How to create script to change a user's password? passwd expects input from keyboard.

I need to create a script which changes the password for a user:

passwd joeblow

The problem is passwd now expects input from the keyboard rather than the script file. I need the script to be non-interactive so how would I script this so you would not have to manually enter the password at the prompt? BTW, it's okay for the password to be viewable in the file, encryption is not necessary for my usage. Thanks for any help!

Last edited by Arodef; 03-02-2005 at 09:27 PM.
Old 03-02-2005, 10:40 PM   #2
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You could try calling a short expect script. Here is an article about it from linux-magazine:

They have an example where they 'spawn' a chsh command, and the expect script responds with the new shell.

I don't know why a here document doesn't work:
passwd <<+++

I suspect that this may be something not allowed by


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto change system password policies (passwd length, complexity) tisource Linux - Security 3 09-06-2005 12:01 AM
which linux c function can change user's passwd henryluo Programming 1 07-15-2005 10:16 PM
Create custom user's directory with simple script dtournas Programming 2 09-09-2004 05:00 AM
need a script that can change the passwd bahadur Linux - Security 1 07-09-2004 05:07 AM
Bash script to edit passwd without Root password? NetFlash Linux - Newbie 2 11-29-2003 04:22 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:09 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration