Yes, you can set a temporary lock on a user account by using the chage command to specify an expiration date for the account. This will effectively lock the account after the specified date. Here’s how to do it:
-
Open a terminal.
-
Run the following command, replacing
usernamewith the actual username andYYYY-MM-DDwith the desired expiration date:sudo chage -E YYYY-MM-DD username
For example, to lock the account on December 31, 2023, you would use:
sudo chage -E 2023-12-31 username
After the specified date, the user will not be able to log in until the expiration is removed or changed.
To check the current expiration date for a user account, you can use:
sudo chage -l username
If you want to remove the expiration date and unlock the account, you can set it to never expire with:
sudo chage -E -1 username
This will allow the user to log in without any restrictions.
