Password aging chage Ubuntu: 7-Step Secure Expert Guide


Last Updated2026-08-01


Reading Time8 minutes


DifficultyIntermediate


CategoryOperating Systems / Ubuntu

Introduction

Password aging chage Ubuntu is covered in this complete practical tutorial. Password aging with chage on Ubuntu enforces periodic password changes to mitigate security risks from compromised credentials. This configuration ensures users update passwords at defined intervals, reducing the window for unauthorized access. The chage utility, part of Ubuntu’s system tools, integrates with the OS’s authentication lifecycle to enforce password policies. By setting expiration and warning days, administrators harden security boundaries while maintaining compliance with resource controls and auditability requirements. This tutorial covers configuring, verifying, and securing password aging using chage on Ubuntu 24.04 LTS.

Version note: These instructions target 7. Package versions and repository behavior may change in later releases, so verify upstream documentation before applying production changes.

What You’ll Learn

This guide explains Password aging chage Ubuntu with clear, reproducible administration steps.

  • Configure password aging parameters using chage.
  • Verify password settings with observable evidence.
  • Troubleshoot common failures in password aging enforcement.
  • Apply security best practices for least privilege and auditability.

Prerequisites

Before you begin Password aging chage Ubuntu, confirm the following prerequisites.

To enforce password aging with chage, ensure the following:

  1. A Ubuntu 24.04 LTS system with sudo access.
  2. Basic familiarity with command-line tools like sudo, chage, and journalctl.
  3. A test user account to apply settings without affecting production accounts.

Lab Environment

The lab environment used to demonstrate Password aging chage Ubuntu is summarized below.

Set up a controlled environment for testing:

  • Create a non-root user (e.g., testuser) with a temporary password.
  • Ensure chage is installed via the default Ubuntu repository.
  • Configure a journalctl log filter for password-related events.
Architecture diagram for Password aging chage Ubuntu: 7-Step Secure Expert Guide
Figure 1. Architecture for Password aging chage Ubuntu: 7-Step Secure Expert Guide.

Installation

the service environment

The chage utility is included in Ubuntu’s base installation. Verify its presence with:

which chage

If absent, install via the official repository:

sudo apt update  
sudo apt install passwd-utils

This ensures package provenance and repository trust via /etc/apt/keyrings and signed-by mechanisms. Avoid third-party repositories to maintain security hardening.

Alternative Installation and Package Sources

Compare the distribution-supported package with the project’s official repository or installation method. Choose one source, document it, and avoid mixing package origins.

Before changing package sources, record the current package version and repository origin. This makes troubleshooting and rollback more predictable.

Expert Architecture Notes

Experienced administrators define service boundaries before tuning individual settings.

  • Treat APT sources, packages, services, kernel, and bootloader as one managed dependency graph.
  • Separate routine updates from release upgrades and document third-party repositories.
Installation workflow diagram for Password aging chage Ubuntu: 7-Step Secure Expert Guide
Figure 2. Installation workflow for Password aging chage Ubuntu: 7-Step Secure Expert Guide.

Configuration

After the initial setup, the Linux setup requires the following configuration checks.

Use chage to set password aging parameters. Run as root or with sudo:

sudo chage -M 90 -W 14 testuser

Review the command output before continuing, and confirm that it completed without errors.

  • -M 90: Sets password expiration to 90 days.
  • -W 14: Issues a warning 14 days before expiration.

For full configuration, review chage’s options with man chage. Adjust parameters based on security policies. Always document changes for auditability.

Configuration and File Reference

ItemPurpose
/etc/enforce/Configuration or persistent data location to back up and review before changes.
/var/log/enforce/Primary log location or log directory used during diagnosis.

Paths can vary by distribution and installation method. Confirm each path on the target host before editing or automating it.

Upgrade and Maintenance Workflow

Use a staged maintenance process: capture the current version, back up configuration and data, review available packages, apply the update, and complete the same verification checks used after installation.

sudo apt update
sudo apt install --only-upgrade enforce

Run upgrade commands during a maintenance window. Review package changes before confirmation, then verify the service, logs, listening ports, and application behavior.

Expert Performance Guidance

Performance changes should follow measurement, not assumptions.

  • Measure boot time, memory pressure, disk latency, and service startup before changing kernel or sysctl settings.
  • Keep /boot and root filesystem capacity monitored before large upgrades.

Monitor the signals that prove whether the change helped or introduced risk.

  • Monitor failed systemd units, pending reboots, disk space, and security updates.
Configuration map diagram for Password aging chage Ubuntu: 7-Step Secure Expert Guide
Figure 3. Configuration map for Password aging chage Ubuntu: 7-Step Secure Expert Guide.

Verification

For upstream details and current platform guidance, consult the Ubuntu Server documentation.

Use these checks to verify that the procedure completed successfully.

Confirm settings with observable evidence:

chage --list testuser

Output should show expiration and warning days. Check logs for enforcement attempts:

journalctl -u passwd --since "1 hour ago"

Successful verification includes:
– User-specific settings in /etc/shadow (view via cat /etc/shadow | grep testuser).
– Log entries indicating password change reminders or expirations.

Troubleshooting

If this configuration does not work as expected, review these common causes.

Common failure modes and resolutions:

  1. Command not found: Ensure chage is installed and in $PATH.
  2. Permission denied: Run chage with sudo or as root.
  3. Settings not applied: Verify /etc/shadow entries match chage output.
  4. User ignores warnings: Enforce mandatory changes via group policies or script automation.

Isolate failures by testing with a disposable user account before applying to production.

Logs and Diagnostic Commands

When the service behaves unexpectedly, collect evidence before changing configuration. The following commands establish the installed version, service state, recent errors, and application-level health.

enforce --version
systemctl status enforce --no-pager
journalctl -u enforce -n 100 --no-pager
journalctl -u enforce --since '30 minutes ago'
systemctl status enforce --no-pager

Save the relevant output with timestamps. Compare the first error with later secondary failures, because the earliest failure usually identifies the root cause.

Rollback and Uninstall Strategy

A rollback should restore both configuration and compatible application data. Do not remove data directories until backups have been verified and the retention decision is documented.

sudo cp -a /etc/enforce /etc/enforce.backup
sudo systemctl restart enforce
sudo apt remove enforce

Package removal does not always delete configuration or persistent data. Inspect the package manager output, verify backups, and confirm whether a purge is appropriate before deleting retained files.

Automation and Routine Health Checks

Automate read-only health checks before automating changes. A scheduled check should report a failure without repeatedly restarting services or hiding the original error.

systemctl is-active enforce
journalctl -u enforce -n 20 --no-pager

For fleet management, place the same checks in Ansible, a monitoring agent, or a systemd timer. Keep credentials outside scripts and make maintenance jobs idempotent.

Common Production Failure Modes

Expert concernOperational guidance
Repository driftPPAs can replace distribution packages and block upgrades.
Kernel regressionA new kernel may fail with storage, network, or DKMS modules.
Partial dpkg transactionInterrupted package operations can leave packages unconfigured.

Security Best Practices

Apply these security controls after the deployment is complete.

Enforce least privilege and auditability:

  • Restrict chage usage to administrative accounts only.
  • Log all chage operations via journalctl or auditd.
  • Avoid storing passwords in plaintext; use secure secret management for automated scripts.
  • Regularly review chage configurations during security audits.

Align with system service lifecycle by reviewing chage settings during OS upgrades or role changes.

Production Readiness Checklist

  • Back up configuration and application data before changes.
  • Validate configuration before restarting or reloading the service.
  • Monitor logs, disk usage, resource consumption, and service availability.
  • Document rollback steps and test them outside production.

Record the tested version, configuration checksum, backup location, validation commands, and rollback owner in the change record before production rollout.

Expert Hardening Guidance

Apply controls in layers and verify that security changes do not break required service behavior.

  • Use unattended-upgrades with monitoring and an explicit reboot policy.
  • Prefer AppArmor profiles, least-privilege sudo rules, and minimal exposed services.

Avoid these common operational anti-patterns.

  • Do not mix multiple repositories for the same core package without pinning.

Expert Recovery Strategy

Recovery planning must cover configuration, persistent state, dependencies, and the order in which services return.

  • Retain previous kernels and console access.
  • Save package selections, APT sources, and configuration backups before high-risk changes.

Automate repeatable checks and changes without hiding failures.

  • Use cloud-init or Ansible for repeatable host configuration.

Frequently Asked Questions

How do I set password aging for all users?

Use a script or group policy to apply chage settings system-wide. Example:

for user in $(getent passwd | cut -d: -f1); do  
  sudo chage -M 90 -W 14 $user  
done

Review the command output before continuing, and confirm that it completed without errors.

Can users bypass password aging?

No. chage enforces expiration unless the user’s password is reset before the warning period. Admins can override via passwd but should document exceptions.

How do I check if password aging is enabled?

Run chage --list username. If no expiration is set, aging is disabled.

What happens if a password expires?

The user cannot log in until they change their password. Admins receive logs indicating the failure.

Conclusion

Enforcing password aging with chage on Ubuntu strengthens security by reducing credential reuse risks. This tutorial covered configuration, verification, and troubleshooting while adhering to security hardening principles. By integrating chage into system service lifecycle management and audit processes, administrators maintain compliance with resource controls and least-privilege requirements. Regularly review settings and logs to ensure ongoing protection against password-related threats.


Need help? If you run into issues while following this guide, leave a comment with the command output and your Linux version.

Leave a Comment