350-201 Question 275
Single answerDuring a cybersecurity investigation, you are analyzing a compromised Linux server. To locate a suspicious file named 'malware.sh' within the '/var/logs' directory and its subdirectories, which Bash command should you use?
- A
find /var/logs -name malware.sh
- B
ls /var/logs malware.sh
- C
grep malware.sh /var/logs
- D
cd /var/logs && locate malware.sh
Show answer and explanation
Correct answer: A
Explanation
The 'find' command is the most appropriate tool for searching files recursively in a directory structure. By specifying '/var/logs' as the starting directory and using the '-name' option with 'malware.sh', the command will locate the file if it exists in the specified directory or its subdirectories.
- A. Correct.
This command is correct. The 'find' command searches for files recursively within a given directory and its subdirectories, and the '-name' option specifies the name of the file to search for.
- B. Incorrect.
This command is incorrect. The 'ls' command lists files in a directory but does not perform a recursive search or locate files by name.
- C. Incorrect.
This command is incorrect. The 'grep' command is used to search for text patterns within files, not to locate files themselves.
- D. Incorrect.
This command is incorrect. The 'locate' command uses a pre-built database to find files but does not search dynamically for files in a specific directory structure. Additionally, the 'cd' part is unnecessary for this operation.