How to Stop Ubuntu from Automatically Deleting User Accounts

The Expiring Account

In enterprise or educational environments, system administrators frequently configure Ubuntu servers with strict user account policies. One common security measure is account expiration: setting a specific date where a temporary contractor or student’s account is automatically locked or, in some automated setups, completely deleted by a scheduled script. If you are managing an Ubuntu machine and find that a specific user account is suddenly vanishing or becoming completely inaccessible after a certain period, it is highly likely that an expiration date was inadvertently set during the account creation process.

Removing the Expiration Date

To ensure a user has permanent access to the system and stop Ubuntu from automatically locking or deleting the user account based on a timeline, you must modify the account’s aging information using the `chage` utility.

You must perform this action via the terminal with root privileges. Open a terminal (Ctrl+Alt+T or via SSH). To check the current expiration status of a user, type sudo chage -l username (replace “username” with the actual account name). Look at the “Account expires” line. If there is a date listed, you need to remove it. To set the account to never expire, execute the following command: sudo chage -E -1 username. The `-E -1` flag specifically tells the system to remove the expiration date entirely. If you run the `chage -l username` command again, the “Account expires” line should now read “never”. The account is now permanent until manually removed by an administrator.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.