QA
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→

More Linux Commands & SysAdmin Interview Questions

Beginner LevelLinux Commands & SysAdmin

How do Linux File Permissions (chmod, chown, chgrp) work in Octal and Symbolic notation?

Beginner LevelLinux Commands & SysAdmin

What is the Linux Filesystem Hierarchy Standard (/bin, /etc, /var, /usr, /opt, /tmp)?

Beginner LevelLinux Commands & SysAdmin

What are File Descriptors (0=stdin, 1=stdout, 2=stderr) and Redirection (>, >>, 2>&1)?