Password aging help
Hello all :)
I need to change the password expiry period for my existing users. Is there any other way I could do it, so that I dont need to change password aging setting one by one? I mean...a script that takes a variable from a file and update it on the /etc/shadow... Any ideas? All help is very appreciated! - Suze |
Hi,
Code:
for USERNAME in `cat file_with_usernames` Hope this helps. |
Thanks for the help!
I'm wondering if I can just take the name variable from the /etc/passwd or shadow file...coz writing a separate file for the names seems to defeat the purpose of making it an easy task :) Something like : Code:
Thanks a lot again for the code! - Suze |
This code seems to do the trick:
Code:
Usage: chage [-l] [-m min_days] [-M max_days] [-W warn] [-I inactive] [-E expire] [-d last_day] user Usage: chage [-l] [-m min_days] [-M max_days] [-W warn] [-I inactive] [-E expire] [-d last_day] user Usage: chage [-l] [-m min_days] [-M max_days] [-W warn] [-I inactive] [-E expire] [-d last_day] user Usage: chage [-l] [-m min_days] [-M max_days] [-W warn] [-I inactive] [-E expire] [-d last_day] user There were incidentally 4 users whose password aging didnt change...so I guess that was why it was giving me those errors. Any ideas how i can fix it? Thanks in advance! - Suze |
Hi again,
Besides the syntax and some coding isuues, there's another thing you need to be aware of: You probably do not want to change the aging info for non-users (root, daemon,sys,lp etc etc). You need to exclude these from your list. Most distro's use UID's that are 500 or greater for normal users (nobody being an exception, this non-user could have a very high uid, should also be excluded). Check this for your distro! If 500 is the lowest UID for normal users this will get them from your /etc/passwd file: awk -F":" '$3 >= 500 { print $1 }' /etc/passwd Command breakdown: -F":" <= set seperator to : (colon) $3 >= 500 <= check if field 3 is greater or equal to 500 { print $1 }' <= print field 1 (only if $3 >= 500) You will end up with this: Code:
for USERNAME in `awk -F":" '$3 >= 500 { print $1 }' /etc/passwd` If you have any doubts/questions: Just ask :) Hope this helps. |
That works beautifully!! Thank you so much for your help, you've saved me from a great headache!
- Suze |
All times are GMT -5. The time now is 09:05 PM. |