In Ubuntu 22.04, viewing system logs can be accomplished in a variety of ways, depending on the type of logs you want to view. Here are some common methods:
Use log files
Ubuntu uses systemd
as its initialization system, and it provides the journalctl
command to view the logs. To view the system log, open a terminal and use one of the following commands:
-
View all logs:
sudo journalctl
This displays a complete list of system logs.
-
View logs for a specific service:
sudo journalctl -u 服务名称
For example, to view the logs of the SSH service, use
sudo journalctl -u ssh
. -
Review of Japanese history:
sudo journalctl -f
This will show real-time updates to the log.
Use graphical interface tools
Ubuntu also provides a graphical interface tool to view logs, called "Log Viewer" (Logs). To use it:
- Open the application menu.
- Search for and open the Log Viewer or Logs app.
- In this application, you can browse different log files and filter logs by time, importance, etc.
View log files directly
Ubuntu also stores traditional log files, such as those in the /var/log/syslog
and other /var/log
directories. To view these files:
- Open a terminal.
- View these files using the
cat
,less
ortail
commands, for example:
orcat /var/log/syslog
Usetail -f /var/log/syslog
tail -f
to view log file updates in real time.
Using the GUI file manager
If you prefer to use a graphical interface, you can use a file manager to open the /var/log
directory and view the log files directly.
Precautions
- Administrator rights are required to view some log files.
- Make sure you handle log files with caution to avoid unnecessary risks to your system.
- Use the log files in
journalctl
and/var/log
to provide a large amount of system information, including errors, warnings, system messages, etc.