Home>Article>Operation and Maintenance> How to check if the user is locked in Linux

How to check if the user is locked in Linux

青灯夜游
青灯夜游 Original
2022-05-12 18:56:25 10767browse

Method: 1. Execute "passwd -S daygeek" or "passwd --status daygeek". If the output information contains "LK", it means it is locked. 2. Execute "grep daygeek /etc/shadow". If there are two exclamation marks before the password, it is locked.

How to check if the user is locked in Linux

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

Linux method to check whether the user is locked

Method 1: Use the passwd command

Pass The passwd command checks user account lockout status

# passwd -S daygeek 或 # passwd --status daygeek

How to check if the user is locked in Linux

This will output a brief message of the password status for a given account.

  • LK: The password is locked

  • NP: No password is set

  • PS: The password is locked Setup

Method 2: Use the grep daygeek /etc/shadow command

Use the /etc/shadow file to check the locked user account status. If the account is locked, two exclamation points will be added in front of the password.

How to check if the user is locked in Linux

Extended knowledge:

Use the -u switch to run the passwd command to unlock a given user account.

How to check if the user is locked in Linux

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to check if the user is locked in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn