Searching with Grep
Here, I am sharing a very useful and simple example of “GREP” command that can save you a lot of key presses. I know you might still remember the trusted grep command that you have learned in your RHCE Training or RHCSS Training.
Let me explain it with a example.
Suppose I want to look for “failed login” attempts on my server. I know I can just see the /var/log/secure file to check that. But /var/log/secure file in this case also contain a lot of other information which I might not be interested in right now.
So How can you do that?
Check this out:
grep -A 5 -i “failed password” /var/log/secure
This will give you the line containing “failed password” and 5 lines appearing just after it.
“LIKE” = Will make life more easier.