Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reset everyone's passwords

Status
Not open for further replies.

Aaron1940

MIS
Dec 14, 2000
27
0
0
US
Anyone know the command for resetting all user's passwords, so that when they first login that will have to change it.

Using Redhat ES

thanks

PS I'm a newbie

-Aaron
 
In flavours I've used passwd -f <username> will force the user to change their password when they log in the next time. Does this suit your need?
 
thats great, but what if i have to do that for 800 user accounts?

-Aaron
 
You write a script to loop through them:

Code:
for i in `cut -d: -f1 /etc/passwd`
#probably DON'T want to do this!!
do
passwd -f $i
done

But you'd need to be more complicated because there are definitely accounts you don't waant to do that to. So..

Code:
cut -d: -f1 /etc/passwd > somefile


# edit somefile to leave desired members

for i in `cat somefile`
do
passwd -f $i
done

Tony Lawrence
Linux/Unix/Mac OS X Resources
 
Personally, I'd prefer to see
Code:
while read i
do
  passwd -f $i
done < somefile

Just so that we don't try to expand the whole thing in memory at once.

It's probably not a serious issue here but the principle is more important generally.

Better to read on thing at a time and process it than try to read it all at once and then process each record.

One at a time you can process any amount of data. All at once you're limited with memory (particularly if there is a low per user/process limit).


Trojan.

 
That's excellent advice, though with 800 names I doubt he'd see a problem (maybe 8k of memory needed at most? But probably less).

But it's good to keep that in mind as general advice. I tend to forget that construct until I screw up and cat something so humongous as to cause me instant regret :)

Tony Lawrence
Linux/Unix/Mac OS X Resources
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top