Sobes.tech
Junior — Middle

How can you view system logs in Linux?

sobes.tech AI

Answer from AI

In Linux, system logs are usually stored in the /var/log directory. There are several ways to view logs:

  • The journalctl command — used for viewing systemd logs. For example, to view all logs:
journalctl

To view logs in real-time:

journalctl -f
  • Viewing specific log files using cat, less, or tail. For example:
tail -n 100 /var/log/syslog

or

less /var/log/messages
  • To filter by time or service in journalctl, you can use options like:
journalctl -u nginx.service --since today

Thus, for systems with systemd, it is preferable to use journalctl, and for classic systems, viewing files in /var/log is common.