Post

Day 2 - User Expiration: Creating Temporary Accounts

Create Linux users with automatic expiration dates for temporary access management

Day 2 - User Expiration: Creating Temporary Accounts

Creating Time-Limited Users: The Expiration Method

In Linux system administration, sometimes you need to grant temporary access—whether for contractors, interns, or guest users. Instead of remembering to manually disable accounts later, you can bake the expiration right into the user creation process.

The Command: adduser with Expiration

1
sudo adduser -m -e 2026-05-06 sambath

To verify the expiration date and account status:

1
sudo chage -l sambath

Good to Know?

Setting Account Expiry

  • What it does: Locks the account automatically after a certain date
  • Date format: YYYY-MM-DD (example: 2026-05-06)
  • Check expiry: chage -l username
  • Change expiry: sudo chage -E 2026-12-31 username

Managing Temporary Users

  • Smart move: Always add expiry when creating temp accounts
  • Check status: chage -l shows when account expires
  • What happens: Expired accounts = no login, but files stay
  • Delete fully: sudo userdel -r username removes user + home folder

Handy Commands

  • chage : View or change account aging settings
  • usermod -e : Update expiry date for existing users
  • passwd -S : Quick password status check
This post is licensed under CC BY 4.0 by the author.