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.
Asked
Active
Viewed 1,033 times
1 Answers
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