Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-28-2005, 08:42 AM   #1
Registered: Jul 2004
Location: Guntur
Posts: 44

Rep: Reputation: 15
Question Need shell script to set passwords for already created users

hello everybody !

Iam just a Linux newbie. And iam just learning to write shell scrips.
Iam trying to write a shell script which sets passwords for already created users without any sort of furthur interaction.

Suppose, for example, i created 50 users named user1, user2, .... user50.
And i want to set the same usernames as passwords to them by using a shell script.

Iam unable to do it.
So, please help me in writing this shell script. If its simple enough, then please send the script in reply.

Thanks to all in advance.

Old 08-28-2005, 11:31 AM   #2
Registered: Aug 2003
Location: Norway
Distribution: FC4
Posts: 83

Rep: Reputation: 20
A list of users can be found in /etc/passwd . Simply grep for whatever prefix you have on the users, and use cut to extract the usernames.
Then, run passwd on each user.
If you need more details, check out:
Old 08-28-2005, 03:02 PM   #3
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Why not use useradd's -p flag to set the password when you create the accounts?


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding new users via Shell script coolfrog Linux - General 10 12-05-2010 11:47 AM
can I set these flags using a shell script nirav.jani Linux - Security 1 01-12-2005 07:01 PM
How do you set a shell script var with a literal '*'? BrianK Programming 3 06-22-2004 03:11 PM
Cant set passwords for new users ribbones Linux - Newbie 2 09-03-2003 11:52 AM
Linux Users created via Script ??? HOW ?? Lutzer Linux - Networking 1 07-31-2002 05:03 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:36 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