To lock a user in Ubuntu sudo usermod –expiredate 1 [username] Substitute the user’s username where username is shown below.
[code]sudo usermod –expiredate 1 username[/code]
This also can be shortened to
[code]sudo usermod -e 1 username[/code]
To unlock a user
[code]sudo usermod -e -1 username[/code]
This will disable the user both from accessing via password and from accessing via a private key.
You can also expire a user at a future date using
[code]sudo usermod -e YYYY-MM-DD username[/code]
To expire a password and force a user to enter a new password
[code]sudo passwd -e YYYY-MM-DD username[/code]
Related: Managing Users in Ubuntu – Reset Root Password on MySQL Database – Donโt Copy-Paste Directly from Website to Terminal