Command referencejournalctl
journalctl command (Linux / bash / sh / zsh)
What it does
Query and follow logs stored by the systemd journal. When people search for the journalctl command linux logs, they usually want journalctl's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.
Query and follow logs stored by the systemd journal.
Syntax
journalctl [OPTION]... [MATCH...]
Common options
| Flag / option | Meaning |
|---|---|
| -u UNIT | Show messages for one unit. |
| -f | Follow newly appended messages. |
| -b | Restrict output to a boot. |
| --since TIME | Show entries since a date or relative time. |
| -p PRIORITY | Filter by priority. |
Practical examples
Service logs
journalctl -u nginx.service
Shows journal entries for nginx.
Follow errors
journalctl -f -p err
Streams new error-priority messages.
Current boot
journalctl -b --since '1 hour ago'
Shows recent messages from this boot.
Common mistakes
- Running without filters and being overwhelmed by the full journal.
- Forgetting elevated permissions may be needed to see system messages.
Related commands
- systemctlControl and inspect services and other systemd units.
- tailPrint the end of input and optionally follow appended data.
- grepSearch text for lines matching a pattern.
- Get-ServiceRetrieve service controller objects and current service states.
- exportMark shell variables for inheritance by child processes.
- setDisplay, create, or remove CMD environment variables.
- shutdownShut down, restart, sign out, or schedule power actions.
- dateDisplay or format the system date and time.
FAQ
What does journalctl do in Linux?
Query and follow logs stored by the systemd journal.
How do I use journalctl from the terminal?
Start with `journalctl [OPTION]... [MATCH...]`, then choose only the options needed for the task.
What is a practical journalctl example?
Try `journalctl -u nginx.service` — Shows journal entries for nginx.
Can I use journalctl in a shell script?
Yes. journalctl works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.