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`
do
echo $USERNAME
#chage <options> $USERNAME
done
I commented out the chmod part and added an echo statement. This is for testing. Make sure all is well before actually using the chage ....... line!!!
If you have any doubts/questions: Just ask
Hope this helps.