0

I want to change the PASS_MIN_DAYS = (whatever value is set) to PASS_MIN_DAYS = 15 using a script.The file it's in is /etc/login.defs.

dessert
  • 39,982

1 Answers1

3

I’d use sed like this:

sed '/^PASS_MIN_DAYS/s/[0-9]\+/15/'

This replaces the number in the line beginning with “PASS_MIN_DAYS” with 15. To edit the file in place leaving a backup with the .bak extension, use the following command. By default you need root access to edit the file.

sed -i.bak '/^PASS_MIN_DAYS/s/[0-9]\+/15/' /etc/login.defs
dessert
  • 39,982