Collect diagnostic archives from Compute Engine Linux virtual machine (VM)
instances to help [Cloud Customer Care](https://docs.cloud.google.com/support/docs/overview.md.txt) investigate
operating system (OS) issues. Use the `sosreport` tool on most Linux
distributions, or use the `supportconfig` tool on SUSE Linux.

For Container-Optimized OS VMs, see
[Collecting debugging information using
sosreport](https://docs.cloud.google.com/container-optimized-os/docs/how-to/sosreport).
For Windows Server VMs, see
[Collecting diagnostic information](https://docs.cloud.google.com/compute/docs/troubleshooting/collecting-diagnostic-information.md.txt).

## Before you begin

- Make sure that you have `sudo` privileges on the Linux VM and can connect to it by using SSH. For more information, see [Connect to Linux VMs](https://docs.cloud.google.com/compute/docs/connect/standard-ssh.md.txt).
- If you haven't already, set up [authentication](https://docs.cloud.google.com/compute/docs/authentication.md.txt). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:

  Select the tab for how you plan to use the samples on this page:

  ### Console


  When you use the Google Cloud console to access Google Cloud services and
  APIs, you don't need to set up authentication.

  ### gcloud

  1.
     [Install](https://docs.cloud.google.com/sdk/docs/install) the Google Cloud CLI.

     After installation,
     [initialize](https://docs.cloud.google.com/sdk/docs/initializing) the Google Cloud CLI by running the following command:

     ```bash
     gcloud init
     ```


     If you're using an external identity provider (IdP), you must first
     [sign in to the gcloud CLI with your federated identity](https://docs.cloud.google.com/iam/docs/workforce-log-in-gcloud.md.txt).

     > [!NOTE]
     > **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.

  2. [Set a default region and zone](https://docs.cloud.google.com/compute/docs/gcloud-compute.md.txt#set_default_zone_and_region_in_your_local_client).

## Why Customer Care needs diagnostic information

When Customer Care troubleshoots complex VM issues, engineers often
need to inspect the internal state of the guest OS. Common examples include
performance bottlenecks, networking problems, OS registration failures, and
errors during package installation or system updates.

To identify the root cause of these issues, support engineers analyze system
logs and configuration files from the VM. A single log or configuration file
rarely provides enough context to resolve the issue, so engineers need a
comprehensive set of system files.

## About the `sosreport` tool

The `sosreport` tool, also known as `sos`, is an open-source, extensible
utility for collecting support data on Linux distributions and other Unix-like
operating systems. You can view the source code and learn more in the
[sosreport GitHub repository](https://github.com/sosreport/sos).

Technical support teams use `sosreport` to automatically gather logs and system
information for troubleshooting OS issues. Instead of requiring you to manually
run dozens of commands and copy log files individually, `sosreport` creates a
standardized, compressed archive containing this data.

The tool uses plugins to run system commands and collect relevant files to
capture the state of the machine. Examples of collected information include the
following:

- **Running processes** : the state of active tasks on the system from commands such as `ps`, `pstree`, and `lsof`.
- **Resource usage** : memory usage from the `free` command, disk space from commands such as `df`, and system load from `uptime`.
- **Configuration files for the OS and services** : system and service configuration files, including the contents of directories such as `/etc` that store local service configurations.
- **Hardware and kernel details**: hardware diagnostics, the running kernel version, and loaded kernel modules.
- **Installed software** : a list of installed packages from the package manager, such as the output of `dpkg -l` or `rpm -qa`.

## Install the `sosreport` tool

The package name and installation command depend on the Linux distribution on
your VM. After you connect to your VM, select one of the following options:

### AlmaLinux,
Rocky Linux, Oracle Linux

1. Check whether the `sos` package is installed:

   ```
   dnf list installed sos
   ```
2. If the package isn't installed, install `sos`:

   ```
   sudo dnf install -y sos
   ```

### Red Hat Enterprise
Linux (RHEL)

1. Check whether the `sos` package is installed:

   ```
   dnf list installed "*sos*"
   ```
2. If the package isn't installed, install `sos` and its
   required packages:

   ```
   sudo dnf install -y sos python3-packaging python3-setuptools
   ```

### Ubuntu 26.04+,
Debian 13+

On Ubuntu 26.04 LTS and later, or Debian 13 and later, complete the
following steps:

1. Check whether the `sos` package is installed:

   ```
   apt list --installed sos
   ```
2. If the package isn't installed, install `sos`:

   ```
   sudo apt install sos
   ```

### Ubuntu 18.04-24.04,
Debian 12

On Ubuntu 18.04 LTS to 24.04 LTS, or Debian 12, complete the
following steps:

1. Check whether the `sosreport` package is installed:

   ```
   apt list --installed sosreport
   ```
2. If the package isn't installed, install `sosreport`:

   ```
   sudo apt install sosreport
   ```

For Container-Optimized OS, see
[Collecting debugging information using
sosreport](https://docs.cloud.google.com/container-optimized-os/docs/how-to/sosreport).
For SUSE Linux, skip this section and see
[Collect diagnostic information on SUSE Linux](https://docs.cloud.google.com/compute/docs/troubleshooting/collecting-diagnostic-info-linux-vm.md.txt#collect-suse-diagnostics).

## Generate a `sosreport` archive

Complete the following steps on AlmaLinux, Debian, Oracle Linux, RHEL, Rocky
Linux, and Ubuntu VMs. For Container-Optimized OS, see
[Collecting the sosreport data](https://docs.cloud.google.com/container-optimized-os/docs/how-to/sosreport.md.txt#collecting_the_sosreport_data).

1. Optional: Estimate the disk space required for the archive:

   ```bash
   sudo sos report --batch --alloptions --all-logs --estimate-only
   ```

   The `--estimate-only` flag was introduced in
   [sos 4.3 on GitHub](https://github.com/sosreport/sos/releases/tag/4.3) and
   isn't available in earlier versions, such as the version on Debian 12.

   Verify that the target partition has enough free disk space. By default,
   `sosreport` saves the archive in `/var/tmp/` on most distributions, except
   on Debian and Ubuntu 24.04 LTS and earlier, where it uses `/tmp/`. If free
   space is limited, use the `--tmp-dir` flag to write the archive to a
   partition with more free space.
2. Generate the diagnostic archive:

   ```bash
   sudo sos report --batch --alloptions --all-logs
   ```

   > [!NOTE]
   > **Note:** To obfuscate sensitive information in the archive, include the `--clean` flag when you run `sos report`.

   When the command finishes, `sosreport` prints the path to the generated
   compressed archive, which has a filename similar to
   `sosreport-hostname-YYYY-MM-DD-abcdef.tar.xz`.
3. To avoid permission errors when you retrieve the archive, make your user
   the owner of the archive:

   ```bash
   sudo chown "$(whoami)" SOSREPORT_FILE_PATH
   ```

   Replace `SOSREPORT_FILE_PATH` with the full path to
   the generated `sosreport` archive.

### Common `sosreport` flags

The following table describes commonly used `sos report` flags:

| Flag | Description |
|---|---|
| `--alloptions` | Enables all options for loaded plugins. |
| `--all-logs` | Collects all available logs regardless of size. |
| `--batch` | Runs in batch mode without interactive prompts. |
| `--clean` | Obfuscates sensitive information in the archive. |
| `--estimate-only` | Estimates required disk space for a full `sos` run. |
| `--tmp-dir` | Specifies an alternate temporary directory. |

To view all available flags, check the command help:

```bash
sos report --help
```

## Collect diagnostic information on SUSE Linux

On SUSE Linux VMs, use the `supportconfig` tool from the `supportutils` package
to collect diagnostic information. After you connect to your SUSE Linux VM,
complete the following steps:

1. Check whether `supportconfig` is installed:

   ```bash
   sudo supportconfig -h
   ```

   The `supportconfig` tool is usually preinstalled on SUSE Linux VMs. If it
   isn't installed, install the `supportutils` package:

   ```bash
   sudo zypper install -y supportutils
   ```
2. Generate a system overview report:

   ```bash
   sudo supportconfig -l
   ```

   The `-l` flag gathers additional rotated logs.

   The `supportconfig` tool collects system information, creates a compressed
   archive, and prints the path to the generated file. By default,
   `supportconfig` saves the archive in `/var/log/` with a filename in the
   format
   `scc_HOSTNAME_DATE_TIME.txz`,
   where `HOSTNAME` is the VM hostname,
   `DATE` is the collection date, and
   `TIME` is the collection time.
3. To avoid permission errors when you retrieve the archive, make your user
   the owner of the archive:

   ```bash
   sudo chown "$(whoami)" SUPPORTCONFIG_FILE_PATH
   ```

   Replace `SUPPORTCONFIG_FILE_PATH` with the full path
   to the generated `supportconfig` archive.

## Retrieve the diagnostic archive from the VM

After you generate the diagnostic archive on the VM, download it to your local
machine. Select one of the following options:

### Console

1. In the Google Cloud console, go to the **VM instances** page:

   [Go to VM instances](https://console.cloud.google.com/compute/instances)
2. In the list of VMs, click **SSH** in the row of the VM that contains
   the diagnostic archive.

3. On the SSH-in-browser toolbar, click
   **DOWNLOAD FILE**.

4. For **Path** , in the **Absolute file path** field, enter the full path
   to the diagnostic archive on the VM.

5. Click **Download**.

   The archive downloads to the default download folder on your
   workstation. For more information, see
   [Transfer files using SSH-in-browser](https://docs.cloud.google.com/compute/docs/instances/transfer-files.md.txt#transferbrowser).

### gcloud

If you have the Google Cloud CLI installed locally, copy the archive to your
local machine by using the
[`gcloud compute scp` command](https://docs.cloud.google.com/sdk/gcloud/reference/compute/scp.md.txt):

```bash
gcloud compute scp USERNAME@INSTANCE_NAME:REMOTE_FILE_PATH \
    LOCAL_DESTINATION_PATH \
    --zone=ZONE \
    --project=PROJECT_ID \
    --compress
```

Replace the following:

- `USERNAME`: the username on the VM that owns the diagnostic archive.
- `INSTANCE_NAME`: the name of the VM.
- `REMOTE_FILE_PATH`: the full path to the diagnostic archive on the VM.
- `LOCAL_DESTINATION_PATH`: the destination directory on your local machine.
- `ZONE`: the zone of the VM.
- `PROJECT_ID`: the ID of the Google Cloud project.

Optional: After you retrieve the diagnostic archive, review it for confidential
or personally identifiable information (PII) and mask or remove any sensitive
data before uploading it.

When the archive is ready, attach it to your Customer Care support
case. For more information about uploading attachments to an open case, see
[Update a support case](https://docs.cloud.google.com/support/docs/customer-care-procedures.md.txt#update-cases).

## What's next

- Learn how to [collect debugging information on Container-Optimized OS by using
  the `sosreport` tool](https://docs.cloud.google.com/container-optimized-os/docs/how-to/sosreport).
- Learn how to [collect diagnostic information from Windows Server VMs](https://docs.cloud.google.com/compute/docs/troubleshooting/collecting-diagnostic-information.md.txt).
- Learn how to [create and manage support cases](https://docs.cloud.google.com/support/docs/customer-care-procedures.md.txt).