To check the lock status of a user account in Linux, you can use the passwd command with the -S option. For example:
[root@Linux ~]# passwd -S user user1 LK 2023-01-07 0 99999 7 -1 (Password locked.)
The -S option displays the current status of the specified user’s password, including whether the account is locked or unlocked. In the output above, the LK indicates that the user’s password is locked.
If the account is not locked you will get the following result :
[root@Linux ~]# passwd -S user1 user1 PS 2023-01-25 0 99999 7 -1 (Password set, SHA512 crypt.)
If you want to lock or unlock a user account, you can use the usermod command with the -L or -U options, respectively. For example:
# usermod -L user or passwd -l user # lock the user account # usermod -U user # unlock the user account
Keep in mind that you will need to be logged in as the root user, or use sudo, to perform these actions.
Samba : Installation et Configuration sur Ubuntu 22.04
nmap : les 12 commandes que vous devez connaître
Comment vérifier la version d’apache
How to check the lock status of a user account in Linux
Fail2Ban : How to protect Linux services