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


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



IFS=, read -a members < <(getent group "$group" | cut -d: -f4)

for logname in "${members[@]}"; do
  echo chage -m "$mindays" "$logname"

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

  • That's it! Thank you very much for help, I'm newbie in Ubuntu commands. :) – Bildgun Sep 25 '20 at 16:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.