• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

journalctl Command Examples in Linux

by admin

The journalctl command enables you to view and query log files created by the journal component of the systemd suite. Log information is collected and stored via the systemd journald service. You can use journalctl to print the entire journal log, or you can issue various options with the command to filter the log in a variety of ways, such as matching a service name or only printing messages matching the specified severity level.

The journald service is often used in conjunction with a traditional syslog daemon such as syslogd or rsyslogd. The settings for journald are configured in the /etc/systemd/journald.conf file.

Syntax

The syntax of the journalctl command is:

# journalctl [options] [matches]

journalctl Command Options

The journalctl utility provides a number of options for querying journald log data. Some of the frequently used options are listed in the following table.

Option Used To
-n {number of lines} Specify the number of lines of journal logs to display.
-o {output format} Specify the format of the output. For example: short, verbose, or export.
-f Display the most recent journal entries, and continuously update the display with new entries as they are added to the journal.
-p Filter journal log output by severity (alert, err, warning, notice, info, etc.).
-u Filter journal log output by the specified unit, such as the name of a service.
-b [boot ID] Show log message from the current boot only, or the boot ID specified.

journalctl Command Examples

1. Show all messages with priority level 3 (errors) from this [b]oot:

# journalctl -b --priority=3

2. Show all messages from last [b]oot:

# journalctl -b -1

3. Delete journal logs which are older than 2 days:

# journalctl --vacuum-time=2d

4. [f]ollow new messages (like `tail -f` for traditional syslog):

# journalctl -f

5. Show all messages by a specific [u]nit:

# journalctl -u unit

6. Filter messages within a time range (either timestamp or placeholders like “yesterday”):

# journalctl --since now|today|yesterday|tomorrow --until YYYY-MM-DD HH:MM:SS

7. Show all messages by a specific process:

# journalctl _PID=pid

8. Show all messages by a specific executable:

# journalctl path/to/executable

Filed Under: Linux

Some more articles you might also be interested in …

  1. Using grep to search in reverse
  2. home-manager Command Examples
  3. extrace: command not found
  4. ncat: command not found
  5. “glab mr merge” Command Examples
  6. func: Azure Functions Core Tools: Develop and test Azure Functions locally
  7. CentOS / RHEL : How To Check FC Brocade HBA Firmware
  8. lsscsi: command not found
  9. Examples of creating command alias in different shells
  10. grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright