LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

sg_raw

Send raw SCSI commands to devices

TLDR

Send SCSI command
$ sg_raw [/dev/sg0] [12 00 00 00 24 00]
copy
Send with data in
$ sg_raw -r [36] [/dev/sg0] [12 00 00 00 24 00]
copy
Send with data out
$ sg_raw -s [size] -i [file] [/dev/sg0] [command]
copy
Verbose output
$ sg_raw -v [/dev/sg0] [command]
copy
Show binary response
$ sg_raw -b [/dev/sg0] [command]
copy

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.

INSTALL

sudo apt install sg3-utils
copy
sudo dnf install sg3_utils
copy
sudo pacman -S sg3_utils
copy
sudo apk add sg3_utils
copy
sudo zypper install sg3_utils
copy
nix profile install nixpkgs#sg3_utils
copy

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.

SEE ALSO

sg_inq(1), sginfo(1), lsscsi(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid