How to view Linux VPS logs with journalctl

Print
  • 0

journalctl reads logs from systemd. Use it when a service fails, a game server will not start, SSH is behaving oddly, or you need to see recent system errors.

The most useful form is usually journalctl -u service-name, because it filters the log to one service instead of showing the whole VPS.

  1. Connect to the VPS with SSH.
  2. View recent system logs:
    sudo journalctl -n 100
  3. Follow live logs:
    sudo journalctl -f
  4. View logs for one service, replacing nginx with your service name:
    sudo journalctl -u nginx

    Linux VPS terminal showing journalctl output for the SSH service

  5. Limit logs by time:
    sudo journalctl --since "1 hour ago"
    sudo journalctl -u myserver --since "today"
  6. Print output directly instead of opening the pager:
    sudo journalctl -u myserver --no-pager -n 100

 

Common options

OptionUse
-u serviceShow logs for one service.
-fFollow new log lines live.
-n 100Show the last 100 lines.
--sinceLimit logs to a time range.
--no-pagerPrint output directly instead of opening the pager view.

When troubleshooting a failed service, start with the newest lines first. The useful error is usually near the bottom of the output, directly after the latest start attempt.


Was this answer helpful?

Related Articles

« Back

Follow us on Social Media

Stay in the loop! Follow our social media accounts and stay up-to-date with the latest news, announcements, tips & tricks and behind-the-scenes insights!