OS Manuals

/usr/bin/sg_raw

SCSI utilities for Linux, Unix and Windows

From sg3-utils 1.49-r3 (enterprise-packages), captured 2026-11-08 by running sg_raw --help (exit 0). permalink

Usage: sg_raw [OPTION]* DEVICE [CDB0 CDB1 ...]

Options:
  --binary|-b            Dump data in binary form, even when writing to
                         stdout
  --cmdfile=CF|-c CF     CF is file containing command in hex bytes
  --cmdset=CS|-C CS      CS is 0 (def) heuristic chooses command set;
                         1: force SCSI; 2: force NVMe
  --enumerate|-e         Decodes cdb name then exits; requires DEVICE but
                         ignores it
  --help|-h              Show this message and exit
  --infile=IFILE|-i IFILE    Read binary data to send (i.e. data-out)
                             from IFILE (default: stdin)
  --nosense|-n           Don't display sense information
  --nvm|-N               command is for NVM command set (e.g. Read);
                         default, if NVMe fd, Admin command set
  --outfile=OFILE|-o OFILE    Write binary data from device (i.e. data-in)
                              to OFILE (def: hexdump to stdout)
  --raw|-w               interpret CF (command file) as binary (def:
                         interpret as ASCII hex)
  --readonly|-R          Open DEVICE read-only (default: read-write)
  --request=RLEN|-r RLEN    Request up to RLEN bytes of data (data-in)
  --scan=FO,LO|-Q FO,LO    scan command set from FO (first opcode)
                           to LO (last opcode) inclusive. Uses given
                           command bytes, varying the opcode
  --send=SLEN|-s SLEN    Send SLEN bytes of data (data-out)
  --skip=KLEN|-k KLEN    Skip the first KLEN bytes when reading
                         data to send (default: 0)
  --timeout=SECS|-t SECS    Timeout in seconds (default: 20)
  --verbose|-v           Increase verbosity
  --version|-V           Show version information and exit

Between 6 and 260 command bytes (one or two hex digits each) can be
specified and will be sent to DEVICE. Lengths RLEN, SLEN and KLEN are
decimal by default. Bidirectional commands accepted.

Simple example: Perform INQUIRY on /dev/sg0:
  sg_raw -r 1k /dev/sg0 12 00 00 00 60 00
Options (17)
OptionDescriptionSource
--cmdfile, -c CF|-cCF is the name of a file which contains the command to be executed.help + man
--cmdset, -C CS|-CCS is a number to indicate which command set (i.e. SCSI or NVMe) to use.help + man
--infile, -i IFILE|-iRead binary data to send (i.e. data-out) from IFILE (default: stdin)help + man
--outfile, -o OFILE|-oWrite binary data from device (i.e. data-in) to OFILE (def: hexdump to stdout)help + man
--request, -r RLEN|-rExpect to receive up to RLEN bytes of data from the DEVICE.help + man
--scan, -Q FOscan command set from FO (first opcode) to LO (last opcode) inclusive.help + man
--send, -s SLEN|-sRead SLEN bytes of data, either from stdin or from a file, and send them to the DEVICE.help + man
--skip, -k KLEN|-kSkip the first KLEN bytes when reading data to send (default: 0)help + man
--timeout, -t SECS|-tWait up to SECS seconds for command completion (default: 20).help + man
-b, --binaryDump data in binary form, even when writing to stdout. (in the manual page but not in --help)man
-h, --helpDisplay usage information and exit. (in the manual page but not in --help)man
-n, --nosenseDon't display SCSI Sense information. (in the manual page but not in --help)man
-N, --nvmWhen sending NVMe commands, the Admin command set is assumed. (in the manual page but not in --help)man
-w, --rawinterpret CF (i.e. the command file) as containing binary. (in the manual page but not in --help)man
-R, --readonlyOpen DEVICE read-only. (in the manual page but not in --help)man
-v, --verboseIncrease level of verbosity. (in the manual page but not in --help)man
-V, --versionDisplay version and license information and exit. (in the manual page but not in --help)man
Exit status (1) from the manual page
0it is successful

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.