The journalctl
command is a utility for querying and displaying messages from the journal, which is a component of the systemd system and service manager. It allows users to access logs from various sources, including system services, kernel messages, and user applications.
The basic syntax of the journalctl
command is as follows:
journalctl [options] [arguments]
-b
: Show logs from the current boot only.-f
: Follow the log output in real-time, similar to tail -f
.--since
: Show logs since a specific date/time.--until
: Show logs until a specific date/time.-u <unit>
: Show logs for a specific systemd unit (service).-p <priority>
: Filter logs by priority level (e.g., info
, warning
, error
).Here are some practical examples of using journalctl
:
journalctl
journalctl -b
journalctl -f
journalctl -u ssh.service
journalctl --since "2023-10-01 10:00:00"
journalctl --until "2023-10-01 12:00:00"
journalctl -p warning
journalctl -b -1
to view logs from the previous boot, which can be helpful for troubleshooting.journalctl -u nginx.service -b
.grep
in conjunction with journalctl
to search for specific keywords in the logs, like so:
journalctl | grep "error"