Beginner LevelLinux Commands & SysAdmin
How do cat, less, head, and tail inspect text file contents?
❓ Interview Prompt: Explain cat, less pagination, head -n, and tail -f live log tracking.
Inspecting text files relies on specialized CLI utilities:
•
'cat file': Dumps complete file contents to terminal.
•
'less file': Scrollable pagination (press 'q' to quit, '/' to search).
•
'head -n 20 file': Displays the first 20 lines of a file.
•
'tail -f -n 50 file': Displays last 50 lines and streams live file additions (essential for monitoring application logs!).
Code Implementation Example
bash
# Stream live updates of Nginx error log
tail -f -n 100 /var/log/nginx/error.log
# Inspect top 15 lines of configuration file
head -n 15 /etc/hosts💡Streaming live log additions using tail -f.
🎯 Interview Key Takeaway
Use tail -f to monitor live log additions, and less for scrollable file inspection.
#tail#head#less#cat#Log Tracking#Beginner
Back to all Linux Commands & SysAdmin Questions→