Hello! Let’s see how to use journalctl, but first let’s see a little more information about what it is.
What is journalctl?
Journalctl is a command-line tool used on Linux-based operating systems to view and manage the system log. Therefore, you can use journalctl on any Linux operating system that uses the “systemd” system log service.
Systemd is a system and service manager used in many modern Linux operating systems, such as Ubuntu, Debian, CentOS, Fedora, Red Hat Enterprise Linux and others. If your Linux operating system uses systemd, then you can use journalctl to view and manage the system log.
This tool is used to view and search for system messages and to perform diagnostic and troubleshooting tasks.
The system log is a file that stores information about events that occur on the system, such as errors, warnings and other messages. With journalctl, you can view these messages in an easier and more organized way, filtering by date, priority, unit or process, among other options.
How to use journalctl
To use journalctl, you must first open a console or terminal on your Linux operating system. Then, you can use the command “journalctl” followed by different options and parameters to view and manage the system log.
Here are some examples of how you can use journalctl:
- To view all system messages in reverse chronological order (i.e., from the most recent to the oldest), simply type “journalctl” and press Enter:
- To view the last day’s system messages, type “journalctl –since yesterday” and press Enter:
journalctl --since yesterday
- To view system messages for a specific date range, you can use the “–since” and “–until” option along with a date in the format “YYYYY-MM-DD HH:MM:SS”. For example, to view system messages from January 1 to December 31, 2021, type:
journalctl --since "2021-01-01 00:00:00" --until "2021-12-31 23:59:59"
- To view the system messages of a specific unit, such as a service or daemon, you can use the “-u” option followed by the unit name. For example, to view messages from the network service “systemd-networkd”, type:
journalctl -u systemd-networkd
- To view the system messages of a specific process, you can use the “-p” option followed by the priority identifier of the message. Priorities range from “emerg” to “debug”. For example, to view all system error messages, type:
journalctl -p err
These are just some basic examples of how you can use journalctl. There are many more options and parameters available, such as “–follow” to track real-time output, “–output” to specify the output format or “–system” to see only system messages. You can see the full list of options and parameters in the journalctl documentation or by typing “man journalctl” in the console.