A log is a record of what happened, and most trouble leaves a trace in it before you notice anything else. The skill is asking it a narrow question and letting a pipeline answer with a count.
Each one is marked as you go, and the explanation arrives straight after, which is
the part worth reading.
4 questions, marked as you go.
Tasks
These need your own device. Run the command in Termux, then paste what it printed.
The marking looks at what the output means, so spacing, version numbers and
ordering do not matter. If you have not installed anything yet, the
lesson covers the setup.
Count the failed logins per source
This writes a short auth log into your home directory, keeps only the failed lines, reduces each one to its source field, and ranks the sources by how many failures each produced.
Run this in Termux
On your own device. Nothing on this page executes it. The command runs in
your terminal, and this box only reads what you paste back.
{ for i in 1 2 3 4 5 6; do echo "user=mira src=203.0.113.14 result=fail"; done; for i in 1 2; do echo "user=root src=198.51.100.7 result=fail"; done; echo "user=dev src=192.0.2.55 result=fail"; echo "user=mira src=203.0.113.14 result=ok"; } > ~/auth.log; grep "result=fail" ~/auth.log | cut -d" " -f2 | sort | uniq -c | sort -nr
Three lines, each a count followed by a source. The top count should stand well clear of the others.
the busiest source is counted as six failures
the next source is counted as two
only failed attempts are counted
the commands actually ran
What a good answer looks like
Three lines, each a count then a source, largest first: 6 src=203.0.113.14 on top, then 2 src=198.51.100.7, then 1 src=192.0.2.55. The counts add up to nine, which is how many failed lines the file holds. The top source has six failures against the next one's two, so it stands out and is the one to read around. The two result=ok lines are absent, because grep kept only the failures before any counting began. Leaving out the sort in the middle would make uniq -c count each source separately, and the numbers would be wrong.
Marking your own work
Both halves of this are checked in your browser, with no server involved, so nothing
stops you from pasting output you did not run. The tasks are written so that the
easiest way to pass one is to actually do it and read the result, which is the whole
intention.