passwd


 
Thread Tools Search this Thread
Operating Systems HP-UX passwd
# 1  
Old 03-02-2007
passwd

Dear frnds,

I have 250 users in passwd file with different passwords, how i can change the password to username+99. pls help out.

regards
# 2  
Old 03-02-2007
cat /etc/passwd | head -100 | tail -1 && passwd <the-result>
I think this can be done with sed also.
# 3  
Old 03-02-2007
Quote:
Originally Posted by sysgate
cat /etc/passwd | head -100 | tail -1 && passwd <the-result>
I think this can be done with sed also.
From what I understand he doesn't want to change the password for the user who is on line 99 in the password file, but for all users in the password file he wants to set the password equal to the username added with +99.

If this is the case you have to be very carefull about it.

Do NOT change the password for system related accounts, some of them are
locked for a good reason.

Furthermore, it is not wise to set passwords to such a simple pattern, especially when your system can be reached from the outside world. Because your system will be hacked in no time.

Please clarify first if you actually want to set the password for each user to "<username>+99".

If this is the case, and it is really what you want, we can take it further from there.
# 4  
Old 03-03-2007
Dear sb,
thanks for your query, I actually mean it, because we r just to launch the new hp ux11i. I already set a common password for all the users, but now mngmt wants to set it as username added with 99 as initial password. later they can change. pls help me out.....

regards
# 5  
Old 03-03-2007
Quote:
Originally Posted by jestinabel
Dear sb,
thanks for your query, I actually mean it, because we r just to launch the new hp ux11i. I already set a common password for all the users, but now mngmt wants to set it as username added with 99 as initial password. later they can change. pls help me out.....

regards
Like I said before, make sure you only change the passwords of "real" users and not of system related accounts.

Hopefully your "real" users are assigned a specific range for the uid (field 3 in /etc/passwd) and no other accounts have an uid within this range.

Now lets assume the uid of a "real" user is between 5000 and 7000.

Then the following script might do the job for you. The script assumes that "expect" is available on your system. You might have to replace "nawk" by "awk".

Code:
#!/usr/bin/ksh

for USER in `nawk 'BEGIN { FS=":" } { if ($3 >= 5000 && $3 <= 7000) print $1 }' /etc/passwd`
do
  expect -c "
    spawn passwd ${USER}
    expect \"New Password: \"
    send \"${USER}99\r\"
    expect \"Re-enter new Password: \"
    send  \"${USER}99\r\"
    expect eof" > /dev/null 2>&1
done

# 6  
Old 03-03-2007
Thanks, sb008, good solution.
Quote:
Originally Posted by sb008
The script assumes that "expect" is available on your system. You might have to replace "nawk" by "awk".
There is a sticky thread at the top of the HP-UX forum with a link to a freeware site. A precompiled and ready-to-install version of "expect" can be found there. On HP-UX the program called "awk" is actually "nawk" so you will need that change.
# 7  
Old 03-04-2007
Thanks to sysgate & perdobo and special thanks to sb, I will try it in the weekend holiday.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passwd -s

Hi, I've a problem regarding understanding of result of passwd -s command. > passwd -s abc PS 05/24/12 0 441 I'm not a super user. But i need to write a simple code for checking password expiry and send an email to the team id. Is there any other command or way to achieve this?... (6 Replies)
Discussion started by: sam_bd
6 Replies

2. AIX

When did AIX start using /etc/security/passwd instead of /etc/passwd to store encrypted passwords?

Does anyone know when AIX started using /etc/security/passwd instead of /etc/passwd to store encrypted passwords? (1 Reply)
Discussion started by: Anne Neville
1 Replies

3. UNIX for Dummies Questions & Answers

etc/passwd help

Hi! i've been searching a way to display the users who are in the /etc/passwd directory...using ls or grep or cat command should do it?i can't find a way to get this right..i mean none of the preview commands function sounded good to me to use... (9 Replies)
Discussion started by: strawhatluffy
9 Replies

4. UNIX for Dummies Questions & Answers

passwd

Hello , how to open utemp,getpwuid files.I know what info these files will carry but i dont know ow to open see the info present in it. Thanks to help. (4 Replies)
Discussion started by: kkalyan
4 Replies

5. Solaris

passwd cmd reenables passwd aging in shadow entry

Hi Folks, I have Solaris 10, latest release. We have passwd aging set in /etc/defalut/passwd. I have an account that passwd should never expire. Acheived by emptying associated users shadow file entries for passwd aging. When I reset the users passwd using passwd command, it re enables... (3 Replies)
Discussion started by: BG_JrAdmin
3 Replies

6. AIX

etc/passwd

Is there any way to allow users to access the etc/passwd file for commands like whoami but not be able to read the file? If I don't put a user in the security group and change the permissions on the etc/passwd file to 640 (rw-r-----) the users can login but the whoami command doesn't work for... (5 Replies)
Discussion started by: daveisme
5 Replies

7. Shell Programming and Scripting

/etc/passwd

Hello All I want to print only the full name from the /etc/passwd file and print it to the screen . Could you please let me know how can I do that? (4 Replies)
Discussion started by: supercops
4 Replies

8. Shell Programming and Scripting

wc /etc/passwd

I have left unix for a long time.Almost forget everthing.:( Anybody can tell me what is the meaning? wc /etc/passwd 9 16 1155 /etc/passwd and $ wc -l /etc/passwd wc -l /etc/passwd 9 /etc/passwd (1 Reply)
Discussion started by: zhshqzyc
1 Replies

9. UNIX for Advanced & Expert Users

no /etc/passwd

Hello ppl, A small mistake of mine has led the /etc/passwd file deleted. So i went to rescue mode and used the following command echo "root::0:0:Superuser:/:/bin/bash" > passwd but that did not get effect in anyway way. when I switch back to normal mode the root is still asking for a passwd.... (3 Replies)
Discussion started by: cyno
3 Replies

10. UNIX for Dummies Questions & Answers

etc/passwd

Can anyone explain the second and third fields in /etc/passwd. Thanks. (2 Replies)
Discussion started by: nguda
2 Replies
Login or Register to Ask a Question