How to use the command 'faillock' (with examples)
- Linux
- November 5, 2023
The ‘faillock’ command is used to display and modify authentication failure record files. It allows users to view login failures of all users, as well as specific users. Additionally, it provides the capability to reset the failure records of a specified user.
Use case 1: List login failures of all users
Code:
sudo faillock
Motivation: This use case is useful when you want to check the login failure records for all users on a system. It can help to identify any potential security issues or unwanted access attempts.
Explanation: The ‘sudo faillock’ command with no additional arguments lists the login failures for all users on the system. It displays the following information: User, Failures, and Last Failure At.
Example Output:
no user is currently locked.
Use case 2: List login failures of the specified user
Code:
sudo faillock --user user
Motivation: This use case is valuable when you want to view the login failure records of a specific user. It allows you to analyze the authentication attempts and identify any potential malicious activities.
Explanation: The ‘sudo faillock –user user’ command lists the login failures of the specified user. It requires the ‘sudo’ command to execute with administrative privileges. ‘user’ should be replaced with the actual username of the user whose login failures you want to view.
Example Output:
user:
When Failures Maximum Latest failure
2022-03-01 12:34:56 5 5 2022-02-28 23:45:00
Use case 3: Reset the failure records of the specified user
Code:
sudo faillock --user user --reset
Motivation: This use case is useful when you want to reset the login failure records of a specific user. It allows you to give the user a fresh start and removes the previous login failure information.
Explanation: The ‘sudo faillock –user user –reset’ command resets the failure records of the specified user. It requires the ‘sudo’ command to execute with administrative privileges. ‘user’ should be replaced with the actual username of the user whose failure records you want to reset.
Example Output:
Failure records for user were reset successfully.
Conclusion
The ‘faillock’ command provides a convenient way to manage authentication failure record files. By using different options and arguments, users can view login failures for all users or specific users, as well as reset failure records when needed. This command enhances system security by allowing administrators to monitor and manage authentication attempts on their systems.