Let's think about it this way for a second
cat (concatenate) prints an entire file to the terminal all at once — best suited for short files. less is for larger files — you can scroll through page by page and search for text with / (press q to quit). head shows the first 10 lines (by default) of a file, and tail shows the last 10 — if you want a quick look at 'what just happened' in a log file, tail is your best bet. tail -f is the superpower flag for 'live' watching a log file as it grows.
Let's connect this to a real-world scenario
To peek at a small config file, just type cat /etc/hostname. For a large log file, you can page through it with less /var/log/syslog — using cat on a big file can flood the screen and get messy fast. After deploying an app on a server, tail -f app.log becomes your go-to tool for live-monitoring errors.
Let's try it together in the terminal
cat /etc/hostname
less /var/log/syslog
head -n 5 notes.txt
tail -n 5 notes.txt
tail -f app.log # Ctrl+C နဲ့ ရပ်The contents of the hostname file print out as a single line in the terminal.5-minute try-it
Create a file with 20 lines, then run head -n 3 and tail -n 3 on it. Write down how the results differ.
A quick word of caution
Running cat on a binary file (like an image) can spew strange characters into your terminal — if it looks broken, just open a new terminal, no harm done.