Difficulty: Easy
Correct Answer: tail
Explanation:
Introduction / Context:
Log inspection and troubleshooting often require viewing the most recent lines of a growing file. Unix provides a simple utility that, by default, shows the last 10 lines and can follow a file as it grows in real time, making it indispensable for monitoring logs and long-running processes.
Given Data / Assumptions:
Concept / Approach:
The tail command prints the end of files. With no options, it outputs the last 10 lines. Adding -n changes the number of lines, and -f follows the file, printing appended data in real time, which is ideal for tailing logs during service restarts or deployments.
Step-by-Step Solution:
Verification / Alternative check:
Compare with head (first lines) to understand the difference. cat shows the whole file, which is inefficient for very large logs when only the end is needed.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting -n when a different count is required, using tail -f without stopping it in scripts, and tailing the wrong rotated log file. Use tail -F to handle log rotations gracefully.
Final Answer:
tail
Discussion & Comments