« Back to 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

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution.

Mastodon icon