« Back to Systemd: Frequently Asked Questions

How to see the last X lines with journalctl

This article has last been updated at .

How to limit the number of lines with journalctl?

Use the journalctl command and filter the number of entries by using the -n option. This will show only the specified number of lines.

journalctl -u UNIT -n NUMBER

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

Other questions related to Systemd

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

Related articles

Like to learn more? Here is a list of articles within the same category or having similar tags.