A system administrator needs to find occurrences of the word 'refused' in the 'auth.log' file, which indicates failed SSH login attempts, and then count how many times this occurs. Which command will provide the accurate count?
The correct answer is grep -c 'refused' /var/log/auth.log because the -c option in the grep command provides a count of matching lines that contain the pattern specified. In this scenario, it counts the number of lines that have the word 'refused', giving an indication of the number of failed SSH login attempts logged in the 'auth.log' file. The options that include piping with the wc -l command are incorrect because when used with grep's -c option, they are redundant and unnecessarily complicate the command. The option that includes -v is incorrect because this inverts the match and would count all lines that do not contain the word 'refused'.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the 'grep' command do?
Open an interactive chat with Bash
What does the '-c' option in the 'grep' command do?
Open an interactive chat with Bash
What is the difference between 'grep' and 'wc -l'?