Hackbydoing Academy tool guide · Linux command line essentials · free, no login
grep searches text and prints only the lines that match a word or pattern you give it.
grep -i failed /var/log/auth.log
It prints every line in the login log that contains the word 'failed', no matter how it is capitalised.
| -A4 | -A means 'also print lines After each match', and the number stuck to it is its value: here 4, so you see each matching line plus the 4 lines that follow it — handy for seeing what happened right after an error. |
| -E | Use the bigger pattern language (extended regular expressions), so symbols like + ? | and ( ) work as pattern operators without needing backslashes in front of them. |
| -c | Count only: instead of printing the matching lines, grep prints a single number — how many lines matched. |
| -h | Hide the file names: when you search several files at once, grep normally writes each file's name in front of its lines; -h leaves those names off. |
| -i | Ignore case: upper- and lower-case letters count as the same, so 'Failed', 'FAILED' and 'failed' all match. |
| -iE | Two switches stuck together: -i (ignore upper/lower case) plus -E (the bigger pattern language). Letters in a bundle like this each keep their own meaning. |
| -rn | Two switches stuck together: -r searches a whole folder and every folder inside it (recursive), and -n writes the line number in front of each matching line so you can find it again. |
| -v | Flip the search (invert): print the lines that do NOT match the pattern, so you can filter out the noise you already understand. |
Only run grep on systems you own or have explicit, written permission to test — at work that means a signed engagement, at home that means your own lab. Inside Hackbydoing Academy you practice on simulated networks and lab machines built for exactly this, where breaking things is the lesson and no one else's systems are involved. Learning how a tool works also teaches you what it looks like from the defender's chair: the logs it leaves, the traffic it makes, and the settings that shut it down.
Reading about grep is step one. In the Academy you run it yourself, step by step, in guided labs on simulated networks — 185 rooms covering attack and defense, from your first scan to full operations, with a defender's debrief at the end of every room. Founding membership is $9.99/mo for the first 500 members.
Join Hackbydoing Academy →Free from the Hackbydoing Academy — learn cybersecurity by doing: real tools, guided labs, attack and defense, on simulated networks. More free material: Tool Guides index · Free Downloads Library · Hackbydoing Academy · Print this page (Ctrl/Cmd+P) for a clean paper copy.