How to View and Search System Logs

How to View and Search System Logs

Using journalctl (systemd logs)

journalctl              # All logs (oldest first)
journalctl -r           # Newest first
journalctl -f           # Follow live (like tail -f)
journalctl -n 100       # Last 100 lines
journalctl -u nginx     # Logs for a specific service
journalctl -u nginx -f  # Follow nginx logs live
journalctl --since "1 hour ago"
journalctl --since "2026-01-01" --until "2026-01-02"
journalctl -p err       # Only errors (crit, err, warning, info, debug)

Key Log Files

  • /var/log/syslog — general system messages
  • /var/log/auth.log — SSH logins, sudo usage, authentication events
  • /var/log/nginx/access.log — all web requests
  • /var/log/nginx/error.log — Nginx errors
  • /var/log/mysql/error.log — MySQL/MariaDB errors
  • /var/log/fail2ban.log — Fail2Ban ban events

Searching Logs with grep

grep "Failed password" /var/log/auth.log
grep "404" /var/log/nginx/access.log | wc -l
grep -i "error" /var/log/syslog | tail -50

Live Log Tailing

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

Reading Compressed Logs

zcat /var/log/syslog.2.gz
zgrep "error" /var/log/syslog.2.gz
  • 0 utilizatori au considerat informația utilă
Răspunsul a fost util?

Articole similare

Managing Users and Groups

Managing Users and Groups on Linux Proper user management is essential for server security. Avoid...

Managing Services with systemctl

Managing Services with systemctl systemctl is the standard tool for managing services on modern...

Monitoring Server Resources

Monitoring Server Resources Keeping an eye on your server's resource usage helps you identify...

Scheduling Tasks with Cron

Scheduling Tasks with Cron Cron allows you to schedule commands to run automatically at set...

Installing and Configuring Nginx

Installing and Configuring Nginx Nginx is a high-performance web server and reverse proxy widely...