Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-22-2008, 02:54 AM   #1
Registered: Aug 2006
Posts: 153

Rep: Reputation: 16
Give password simultaneously for multiple users

hi every1,

I would like to duplicate present users of a Linux box into another one. I created the users using a shell script. Now can anyone suggest an idea to give same password for all the users simultaneously. (Like all users have the same password and they will change it according to their wish later)

Thanks in advance
Old 02-22-2008, 08:43 AM   #2
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
if you just want them to all have the same password you could run through a for loop.

something like:
for i in user1 user2 user3 user4; do echo password | passwd --stdin ${i}; done
or if you have a filename with one username per line:
for i in $(cat /tmp/users.file); do echo password | passwd --stdin ${i}; done
or more simply set one password and then manually copy the hash from /etc/passwd (or /etc/shadow, if using shadow) and paste it for the remaining;
this isnt very secure (if anyone can read the shadow file they can clearly see that the hashes are the same so identifying the password for one users opens it up for all users) but then again, neither is setting the same password for multiple users. however, it does very from situation to situation as to what you do and why you decide to do it.


you may even be able to modify your shell script used to create the users to modify the password as well depending on its structure and design.

I'm sure there are any number of other possible ways to accomplish this same task; some more easily and some more robust/complex;

Last edited by rayfordj; 02-22-2008 at 08:45 AM.
Old 02-24-2008, 06:46 PM   #3
Registered: Aug 2006
Posts: 153

Original Poster
Rep: Reputation: 16
Thanks a lot buddy. I would try any of these and let u know abt the success. . . . .
Old 02-25-2008, 12:29 AM   #4
Registered: Aug 2006
Posts: 153

Original Poster
Rep: Reputation: 16
Now i hav another quewry.

I hav a file with usernames and another with corresponding userids. I tried a script to create user by accepting username from one file and corresponding id from the other, but the loop executes infinitely. Can any1 help me to create username from both.

Old 02-25-2008, 12:52 AM   #5
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,803

Rep: Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540Reputation: 2540
Show use the code... also, don't you mean create 'user' not 'username' ?


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
Problem accessing Samba shares simultaneously by multiple users SKYNAT Linux - Newbie 2 01-29-2008 05:25 AM
Multiple Blade servers booting from multiple disk drives simultaneously NGC_cheryl Linux - Enterprise 0 11-26-2007 08:38 AM
How do i give root access to multiple users? bakekelwa Linux - Newbie 14 07-19-2007 11:14 AM
1 cpu and 3 users simultaneously using X packets Linux - Hardware 2 03-25-2007 07:21 PM
Two users on 1 PC simultaneously (with X) technobeast Linux - Newbie 1 07-10-2004 06:24 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:15 PM.

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