User Expiry Date Generator
Generate Linux user account expiry dates and commands. Create usermod and chage commands for managing temporary users, contractors, and project-based access with automatic account cleanup.
2024-12-31
2025-06-30
User Expiry Date Generator
Quick Presets
Expiry Configuration
Days after expiry before account is locked
Days before expiry to show warning
usermod Command:
usermod -e 2027-02-21 -f 30 john.doechage Command:
chage -E 2027-02-21 -I 30 -W 7 john.doeNotification Script:
#!/bin/bash
# User Expiry Notification Script
USERNAME="john.doe"
EXPIRY_DATE="2027-02-21"
WARNING_DAYS=7
INACTIVE_DAYS=30
echo "User Account Expiry Management"
echo "Username: $USERNAME"
echo "Expiry Date: $EXPIRY_DATE"
if id "$USERNAME" &>/dev/null; then
usermod -e $EXPIRY_DATE $USERNAME
echo "✅ Expiry date set to $EXPIRY_DATE"
if [ $INACTIVE_DAYS -gt 0 ]; then
usermod -f $INACTIVE_DAYS $USERNAME
echo "✅ Inactive days set to $INACTIVE_DAYS"
fi
if [ $WARNING_DAYS -gt 0 ]; then
chage -W $WARNING_DAYS $USERNAME
echo "✅ Warning days set to $WARNING_DAYS"
fi
echo "Account expiry settings applied successfully!"
else
echo "❌ User $USERNAME does not exist"
exit 1
fi💡Quick Examples
Common Expiry Scenarios:
Best Practices:
What is User Account Expiry?
User account expiry is a security feature in Linux systems that automatically disables user accounts after a specified date. This is essential for managing temporary users, contractors, interns, and ensuring that unused accounts don't become security risks.
Key Concepts
Expiry Date (-e)
The date when the user account will be automatically disabled. After this date, the user cannot log in.
Inactive Period (-f)
Number of days after expiry before the account is completely locked. This provides a grace period.
Warning Days (-W)
Number of days before expiry when the user receives warnings about their account expiration.
Account Status
The current state of the account: Active, Expiring Soon, Expired, or Locked.
Commands Used
usermod Command
The usermod command modifies existing user accounts:
-e YYYY-MM-DD: Set account expiry date-f days: Set inactive period after expiry-L: Lock account immediately-U: Unlock account
chage Command
The chage command manages password aging and account expiry:
-E YYYY-MM-DD: Set account expiry date-I days: Set inactive period after expiry-W days: Set warning days before expiry-l username: List current settings
Use Cases
Temporary Employees
Set expiry dates for contractors, interns, or seasonal workers to automatically disable their accounts.
Project-Based Access
Grant access for specific project durations with automatic account cleanup.
Security Compliance
Ensure accounts are automatically disabled to meet security policy requirements.
Resource Management
Prevent unused accounts from consuming system resources and licenses.
Security Best Practices
- Regular Reviews: Periodically review and update expiry dates
- Documentation: Maintain records of expiry policies and dates
- Notifications: Set up automated notifications for expiring accounts
- Grace Periods: Use appropriate inactive periods for different user types
- Monitoring: Monitor account status and expiry compliance
Monitoring and Maintenance
Check Expiry Status
Use chage -l username to view current expiry settings for any user.
List Expired Accounts
Use chage -l username | grep "Account expires" to check specific users.
Automated Scripts
Create cron jobs to automatically check and report on expiring accounts.
Related Tools
Account Lock/Unlock Script Generator
Generate Linux user account lock/unlock scripts and commands. Create automated scripts for managing account security, password policies, and user access control with comprehensive logging and notifications.
Bind Mount Generator
Generate bind mount configurations for chroot environments, containers, and directory overlays. Create mount commands, fstab entries, and systemd mount units with proper options for various bind mount scenarios.
Command Retry Cron Generator
Create cron jobs with intelligent retry logic and exponential backoff for failed commands. Generate retry scripts, systemd timers, and cron entries with configurable retry strategies.
Scheduler with Random Delay Generator
Generate cron schedules with random delays to prevent thundering herd problems. Add jitter to your scheduled jobs.
Scheduler for Holiday-Safe Execution (skip weekends/holidays)
Create cron schedules that automatically skip weekends and holidays. Generate business-day-only scheduling expressions.
Timezone Cron Adjuster (convert job to UTC)
Convert cron expressions between different timezones. Adjust scheduled jobs for UTC or other timezone requirements.
Stay Updated with Linux Concepts
Get the latest Linux tips, tutorials, and tool updates delivered to your inbox. Join our community of Linux enthusiasts and professionals.
No spam, unsubscribe at any time. We respect your privacy.