Linux View / Display a Logfile In Real Time on Screen

I would like to see my php or apache web server log files in real time. How do I see a log file in real time including all incoming logs on Linux using ssh based session?

You need to use the tail command which output the last part of files in real time including all incoming logs to a standard output device such as screen. This is useful to:

ADVERTISEMENTS

Tutorial details
Difficulty Easy (rss)
Root privileges Yes
Requirements None
Time 2m
  1. View log files in real time.
  2. Debug server problems.
  3. Troubleshoot security issues.
  4. Monitor spammers, ip-address, scripts and more.

tail -f file-name command syntax

The basic syntax is:

tail fileName
tail /path/to/log/file
tail [options] /path/to/log/file

If your log file name is /var/log/lighttpd/access.log, enter:
tail -f /var/log/lighttpd/access.log

If your php log file name is /var/log/lighttpd/scripts.log, enter
tail -f /var/log/lighttpd/scripts.log
Sample outputs:

 47 -> 400 
2013-11-24 21:47:29: (request.c.622) invalid character in key GET /nixcraft/linux/docs/uniqlinuxfeatures/lsst HTTP/1.1
Host: cyberciti.biz
Accept: */*
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0 FirePHP/0.7.4
 
 /5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0 FirePHP/0.7.4
 
 47 -> 400

You will get a scrolling view of the /var/log/lighttpd/scripts.log for all incoming entries on screen. To stop simply hit CTRL+C. Please note that you may need to login as root user to view log files.

Recommend readings
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
2 comments… add one
  • Rogha Dec 15, 2009 @ 23:14

    how do to view this tail -f log.log on a web?

  • Romero May 7, 2011 @ 12:37

    not that simple, u must use ajax.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.