Show the latest failed login attempts with source addresses
Build a paste-ready command, then review its compatibility and effects before running it.
sudo lastb -Fai | head -<count>Complete required fields to copy the generated command.
cautionrequires privileges Compatibility
LinuxVerified for Linux using bash, zsh syntax.
Operational knowledgereview due 2027-01-19
Requirementslastblastb must be installed and available on PATH.Elevated accessReview the exact scope before using an elevated account.
Version supportlastb Current supported releasesVerified for linux using bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signalsadmin ssh:notty 203.0.113.24 Thu Jul 23 09:48:12 2026 - Thu Jul 23 09:48:12 2026 (00:00)Representative successful output; values vary with the selected target and system state.
Known errorslastb: command not foundlastb is missing or is not available on PATH.Permission deniedThe current identity does not have the required access.
Verifysudo lastb -Fai | head -{{count}}Re-run the corresponding read-only inspection and confirm the intended state.Rollback noteNo universal automatic rollback is available. Capture the current state and use the tool-specific recovery procedure before applying changes.
Command breakdown
01sudoPrivilege elevationRuns the following command with elevated privileges after authorization.
02lastbCommandRuns the lastb stage of this one-liner.
03-FaiOptionConfigures lastb with the -Fai option.
04|PipelinePasses the output on the left to the command on the right.
05headCommandRuns the head stage of this one-liner.
06-<count>OptionConfigures head with the -<count> option.
This advanced community-curated one-liner combines several stages. Review every option and placeholder before running it.
Example input
sudo lastb -Fai | head -5
Example output
admin ssh:notty 203.0.113.24 Thu Jul 23 09:48:12 2026 - Thu Jul 23 09:48:12 2026 (00:00)
invalid ssh:notty 198.51.100.9 Thu Jul 23 09:47:41 2026 - Thu Jul 23 09:47:41 2026 (00:00)
Illustrative output — exact values vary by system and data.
Official sources