Linux Terminal Command: journalctl

The journalctl command is an essential tool in System Services & Scheduling. In this tutorial, we will explore what journalctl does, look at everyday examples, and cover advanced options to supercharge your command-line workflow.


Concept & Explanation

The journalctl command queries the logs compiled by systemd, indexing system services, kernel logs, and boot processes.


Common Options & Syntax

journalctl [options] [arguments]

Here are the most common flags used with journalctl:


1. Interactive Example (Simple)

Here is how most people run the command:

# Example
journalctl -u nginx

What it does: Displays logs for the Nginx service.


2. Power-User Example (Advanced)

For scripting and advanced diagnostics, use this configuration:

# Advanced
journalctl -u nginx -n 100 --since '1 hour ago' -f

What it does: Streams the last 100 logs from Nginx recorded in the past hour, updating in real time.


⚙️ Warning & Common Pitfalls

[!WARNING] Journal logs can grow large. Use sudo journalctl --vacuum-time=7d to clean logs older than 7 days.


Here are some related posts on cli_tty1 you might want to check out: