What is the primary purpose of the 'grep' command?
- A.To display disk usage; the PATH variable is consulted only for commands typed with an absolute path
- B.To search for text patterns within files
- C.To compress files
- D.To change file permissions, since the last command reads the authentication log rather than the wtmp database
Why B is correct
grep (Global Regular Expression Print) searches for text patterns in files or command output. For example, 'grep error /var/log/syslog' finds all lines containing 'error' in the syslog file. It is one of the most essential tools for log analysis and security investigations.
Know someone studying for Security Fundamentals? Send them this one.