How to view system logs in ubuntu22.04

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:

  1. View all logs:

    sudo journalctl
    

    This displays a complete list of system logs.

  2. View logs for a specific service:

    sudo journalctl -u 服务名称
    

    For example, to view the logs of the SSH service, use sudo journalctl -u ssh.

  3. 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:

  1. Open the application menu.
  2. Search for and open the Log Viewer or Logs app.
  3. 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:

  1. Open a terminal.
  2. View these files using the cat, less or tail commands, for example:
    cat /var/log/syslog
    
    or
    tail -f /var/log/syslog
    
    Use 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.

Guess you like

Origin blog.csdn.net/sunyuhua_keyboard/article/details/135035673