Linux Tutorial — Part 5: Viewing & Reading Files

In this part, we will learn how to read files in Linux. Linux systems store everything as text — logs, configs, scripts. Knowing how to view files is a core Linux skill.

1. cat — View Entire File

cat prints the entire file content at once. Best for small files.

cat file.txt

Combine files:

cat file1.txt file2.txt

⚠️ cat Limitation

Do not use cat on large files. It will flood your terminal.

2. less — Read Large Files Safely

less opens files in a scrollable viewer. This is the most used file viewer in Linux.

less largefile.log

3. more — Older File Viewer

more is similar to less but limited. Less is preferred in modern systems.

more file.txt

4. head — View Top Lines

Shows the first 10 lines of a file by default.

head file.txt

Custom number of lines:

head -n 5 file.txt

5. tail — View Last Lines

Shows the last 10 lines. Very useful for logs.

tail file.txt

Live log monitoring:

tail -f /var/log/syslog

6. watch — Re-run Command Automatically

Runs a command repeatedly every 2 seconds.

watch tail file.txt

Real World Example

Server admins use:

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

This allows real-time monitoring.

Important Mindset

Linux is about observing systems. Logs tell the truth before dashboards do.

In the next part, we will learn how to search text inside files using powerful Linux tools.

Next: Searching Text with grep →
Disclaimer:
Some log files require root permissions. Use sudo only when necessary.