
sosreport Command in Linux
The sosreport command is a diagnostic tool used in Linux systems to collect system configuration, logs, and other important information for troubleshooting and analysis. It is commonly used in enterprise environments, especially with Red Hat-based distributions like RHEL, CentOS, and Fedora, to assist technical support teams in diagnosing issues.
Table of Contents
Here is a comprehensive guide to the options available with the sosreport command −
- Understanding the sosreport Command
- How to Use sosreport Command?
- Syntax of sosreport Command
- Installation of sosreport Command
- sosreport Command Options
- Examples of sosreport Command in Linux
- Configuration of sosreport Command
- Monitoring sosreport Command
Understanding the sosreport Command
The sosreport command in Linux is a vital diagnostic tool used to collect system information for troubleshooting purposes. It gathers a comprehensive set of data, including system configuration files, command outputs, and log files, into a single archive. This archive is then typically provided to support teams, such as those from Red Hat or other Linux vendors, to aid in diagnosing and resolving system issues. The goal is to provide a standardized method for collecting a wide array of information, reducing the need for support personnel to request numerous individual files and outputs.
The sosreport command gathers a comprehensive snapshot of the system's state, including hardware details, software configurations, and logs. It packages this information into a compressed archive that can be shared with support teams for analysis.
Key Features
- Collects system configuration and diagnostic information.
- Supports plugins for specific subsystems and applications.
- Allows customization of the data collected.
- Provides options to obfuscate sensitive information.
How to Use sosreport Command?
A key strength of sosreport lies in its modular design. It uses plugins to collect specific types of data, allowing for customization and expansion. This means that it can be adapted to gather information relevant to various system components and applications. For example, there are plugins for collecting data related to networking, storage, virtualization, and specific software packages. This modularity makes sosreport highly versatile and capable of capturing a broad range of system states
Syntax of sosreport Command
The basic syntax of the sosreport command is −
sosreport [OPTIONS]
Here, OPTIONS indicate Flags to modify the behavior of the command.
Installation of sosreport Command
A key strength of sosreport lies in its modular design. It uses plugins to collect specific types of data, allowing for customization and expansion. This means that it can be adapted to gather information relevant to various system components and applications. For example, there are plugins for collecting data related to networking, storage, virtualization, and specific software packages. This modularity makes sosreport highly versatile and capable of capturing a broad range of system states.
The sosreport command is part of the sos package. To install it, use the following commands −
On Red Hat-based Systems (RHEL, CentOS, Fedora) −
sudo yum install sos
On Debian-based Systems (Ubuntu, Debian) −
sudo apt update sudo apt install sosreport

sosreport Command Options
Here are some of the most commonly used options with the sosreport command −
-a or --all-logs: Collects all available logs, including those that are not enabled by default. For example,
sudo sosreport -a

-o or --only-plugins: Specifies a comma-separated list of plugins to enable. For example,
sudo sosreport -o apache,tomcat

-k or --plugin-option: Sets options for specific plugins. For example,
sudo sosreport -k apache.log=on

âbatch: Runs the command without interactive prompts. For example,
sudo sosreport --batch

--case-id: Specifies a case ID to include in the report. For example,
sudo sosreport --case-id=123456

--tmp-dir: Specifies a temporary directory for storing the report. For example,
sudo sosreport --tmp-dir=/custom/tmp

âclean: Obfuscates sensitive information in the report. For example,
sudo sosreport --clean

--list-plugins: Lists all available plugins. For example,
sudo sosreport --list-plugins

âhelp: Displays help information. For example,
sosreport --help

âversion: Displays version information. For example,
sosreport --version

Examples of sosreport Command in Linux
In this section, let's take a look at some examples of using sosreport −
- Generating a Basic Report
- Generating a Report with All Logs
- Generating a Report for Specific Plugins
- Setting Plugin Options
- Running in Batch Mode
- Specifying a Case ID
- Obfuscating Sensitive Information
- Specifying a Temporary Directory
Generating a Basic Report
sudo sosreport
This command generates a basic report with default settings.
Generating a Report with All Logs
sudo sosreport -a

This command collects all available logs, including those not enabled by default.
Generating a Report for Specific Plugins
sudo sosreport -o apache,mysql

This command collects information only for the Apache and MySQL plugins.
Setting Plugin Options
sudo sosreport -k apache.log=on

This command enables the collection of all Apache logs.
Running in Batch Mode
sudo sosreport --batch

This command runs without interactive prompts, suitable for automated scripts.
Specifying a Case ID
sudo sosreport --case-id=123456

This command includes the specified case ID in the report.
Obfuscating Sensitive Information
sudo sosreport --clean

This command obfuscates sensitive information, such as hostnames and IP addresses.
Specifying a Temporary Directory
sudo sosreport --tmp-dir=/custom/tmp

This command uses a custom temporary directory for storing the report.
Configuration of sosreport Command
The behavior of sosreport can be customized using configuration files. The main configuration file is typically located at /etc/sos.conf.
Example Configuration −
[general] batch = True tmp_dir = /custom/tmp
Where −
- batch − Enables batch mode by default.
- tmp_dir − Specifies a custom temporary directory.
Monitoring sosreport Command
You can monitor the sosreport command using standard Linux tools.
Check Process Status −
ps aux | grep sosreport

View Logs −
tail -f /var/log/sosreport.log

Conclusion
The sosreport command is an essential tool for collecting diagnostic information in Linux systems. By understanding its options and usage, you can effectively troubleshoot and resolve system issues.
In practical use, sosreport simplifies the process of gathering diagnostic data. Instead of manually collecting numerous files and command outputs, administrators can use a single command to generate a comprehensive report. This significantly reduces the time and effort required for troubleshooting, and helps support personnel to more rapidly diagnose problems.
Furthermore, the sosreport command has options that allow for the exclusion of certain data, or the inclusion of very specific data, that can be used to tailor the reports to more specific needs.