Intermediate · 9 min · practise every command in the built-in terminal

journalctl — The systemd Log Viewer

journalctl reads the systemd journal — a centralized log of everything: kernel messages, service output, boot events.

View all logs

journalctl
journalctl -r          # Reverse order (newest first)

Follow logs live (like tail -f)

journalctl -f

Logs for one service

journalctl -u nginx
journalctl -u nginx -f            # Follow live
journalctl -u nginx --since today

Filter by time

journalctl --since "2024-01-15"
journalctl --since "1 hour ago"
journalctl --since "09:00" --until "10:00"

Filter by priority (errors only)

journalctl -p err
journalctl -p err -u nginx

Logs since last boot

journalctl -b            # Current boot
journalctl -b -1         # Previous boot

Limit output

journalctl -n 50         # Last 50 lines
journalctl -u nginx -n 20 --no-pager

Practice tasks

  1. View the logs for the nginx service
  2. Show only the last 50 log lines system-wide
  3. Follow nginx logs live as new entries arrive
  4. Show only error-priority log entries for nginx

Commands in this lesson

Services & systemd