Ask Steves · Daily notes · VPS, 20% off · AI Profit Lab · SEO · Money Hub

17 October 2026 · One command a day

How do I follow a log file on Linux and still scroll back?

less +F opens a log file and shows new lines as they are written, much like tail -f. You can also stop following at any moment, scroll back through the whole file, search it, then carry on following. Use it when something is going wrong right now and you also need to see what happened just before.

I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.

The command

sudo less +F /var/log/nginx/access.log

less is the standard pager on Ubuntu, so you do not need to install anything. The + tells less to run a command as soon as the file opens. F is its "forward forever" command: it jumps to the end of the file and waits for new lines. The path is the file to watch, and you can swap in any log. sudo is there because nginx logs are not readable by every user. Once you are inside, press Ctrl+C to stop following. You can then move around with the arrow keys, g for the top, G for the bottom, or /text to search. Press Shift+F to start following again, and q to quit.

What you will see

127.0.0.1 - - [17/Oct/2026:09:14:02 +0000] "GET / HTTP/1.1" 200 5320 "-" "Mozilla/5.0"
127.0.0.1 - - [17/Oct/2026:09:14:03 +0000] "GET /css/site.css HTTP/1.1" 200 1840 "https://example.com/" "Mozilla/5.0"
127.0.0.1 - - [17/Oct/2026:09:14:07 +0000] "POST /api/login HTTP/1.1" 502 166 "https://example.com/login" "Mozilla/5.0"
Waiting for data... (interrupt to abort)

Each line is one request. It shows the client address, the time, the method and path, the status code and the size of the response. The last line is the less prompt. It tells you less is in follow mode and waiting for more data. New requests appear above it as they arrive. If you spot a 502, press Ctrl+C. The prompt changes to the file name, and you can scroll up to see the requests that came before it.

When to use it

Watch out for

Log rotation. By default, less keeps following the file it opened, even after logrotate renames it. On Ubuntu that happens to nginx logs every day. After a rotation your screen goes quiet while new lines go to a fresh file that less is not watching. Add --follow-name to make less reopen the file by name: sudo less --follow-name +F /var/log/nginx/access.log.

Questions people ask

What is the difference between less +F and tail -f?

tail -f only prints new lines as they arrive. less +F holds the whole file, so you can scroll back and search without leaving. For plain watching, see how to watch the nginx error log in real time.

How do I stop following without closing less?

Press Ctrl+C. Less stays open with the file loaded, and Shift+F puts it back into follow mode. To grab a fixed chunk instead, see how to read the last 50 lines of a log file.

Reading raw server logs live like this needs shell access to the machine, and most shared hosting does not give you that. You can get the same VPS with 20% off at https://asksteves.co.uk/vps. Affiliate link.

Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.

Everything on this blog runs on one Hostinger KVM 8. This link takes 20% off the same box.

GET A VPS, 20% OFF →

Affiliate link.

Related server notes: How do I follow a Docker container's logs on Linux? · How do I watch the nginx error log in real time? · How do I back up a MySQL database from the command line? · All daily notes