📖 How to View Files in Linux Terminal

Learn which Linux command to choose for viewing text files, logs, and configurations.

Comparison of Linux File Viewing Commands

Command Best For Key Advantage
catSmall text files (< 100 lines)Dumps entire content immediately to stdout
lessLarge files & source codeInteractive paging, forward/backward search (/), does not load entire file into memory
headChecking headers or file startDisplays first 10 lines (configurable via -n 50)
tailRecent log entriesDisplays last 10 lines (configurable via -n 20)
tail -fLive monitoring server logsFollows active log writes in real-time
nano / vimEditing & full inspectionTerminal text editors for modifying content

1. Viewing with less (Recommended for Large Files)

$ less /var/log/syslog

Navigation keys: Space (next page), b (previous page), /pattern (search text), q (quit).

2. Monitoring Live Logs with tail -f

$ tail -f /var/log/nginx/access.log

As incoming requests hit Nginx, new log entries stream directly to your terminal screen. Press Ctrl+C to stop.