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.
You love my articles ? Encourage me to write more BuyMeACoffee.
Résoudre l’erreur : WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
Empêcher les utilisateurs sudoers d’exécuter des cmds sudo
Migration de CentOS 7 vers CentOS Stream
Migrer CentOS 7 vers Rocky Linux 9
Fail2Ban : How to protect Linux services