« Back to Systemd: Frequently Asked Questions

How to see the last X lines with journalctl

Sometimes a systemd unit, like a service, should not be starting during boot time or not at all. Let’s have a look how to disable a systemd unit.

See the last few lines

By default, journalctl will display all entries from the journal. To limit this to last X lines, use the -n option and optionally define a number (default: 10 lines).

journalctl -n 5

Limit the output for a service

Combine the number of lines and specify a unit to see more relevant entries.

journalctl -u ssh.service -n 20

Tip: if you query the status output with systemctl, it will also pull the last ten lines from the journal (similar to -n 10).

Learn more about journalctl

This article uses the journalctl command to achieve its tasks. For this popular tool there is a cheat sheet available!

» Mastering the tool: journalctl

journalctl cheat sheet

Other questions related to systemd

Feedback

Is the described answer not working or incorrect, got another tip or question? Share your thoughts!