Glam Prestige Journal

Bright entertainment trends with youth appeal.

How can i use "chage" command to change, for example, minimum number of days before password change for every user in the group?

1 Answer

I don't think there's a one-shot command to do this, so you would need to extract the list of members from the groups database and loop over it - exactly how you choose to do that is up to you but for example

#!/bin/bash
group='group'
mindays=28
IFS=, read -a members < <(getent group "$group" | cut -d: -f4)
for logname in "${members[@]}"; do echo chage -m "$mindays" "$logname"
done

(remove the echo once you are satisfied that it will do the right thing).

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy