sg_raw
Send raw SCSI commands to devices
TLDR
Send SCSI command
SYNOPSIS
sg_raw [-r len] [-s len] [-i file] [options] device cdb
DESCRIPTION
sg_raw sends arbitrary SCSI command descriptor blocks (CDBs) to a device and displays the response. It provides the lowest level of access to SCSI devices, allowing direct transmission of any command without interpretation or validation by the utility itself.
The tool supports all SCSI data transfer phases: commands that read data from the device (-r), commands that write data to the device (-s with -i), and commands with no data transfer. Response data can be displayed in hexadecimal, saved to a file, or output in binary format for further processing.
As part of the sg3_utils package, sgraw is primarily used for device testing, debugging SCSI protocol issues, and sending vendor-specific commands that are not covered by the higher-level sg3utils utilities.
PARAMETERS
-r LEN
Read LEN bytes.-s LEN
Send LEN bytes.-i FILE
Input file.-o FILE
Output file.-v
Verbose.-b
Binary output.-t SEC
Timeout.
CAVEATS
Root required. Can damage devices. Know what you're doing.
HISTORY
sg_raw is part of sg3_utils, a collection of utilities for SCSI devices on Linux.
