{
    "mode": "man",
    "parameter": "sg_opcodes",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/sg_opcodes/8/json",
    "generated": "2026-10-06T09:31:08Z",
    "synopsis": "sgopcodes  [--alpha]  [--compact]  [--enumerate] [--help] [--hex] [--mask] [--mlu] [--no-in‐\nquiry] [--opcode=OP[,SA]] [--pdt=DT] [--raw] [--rctd] [--repd] [--sa=SA] [--tmf] [--unsorted]\n[--verbose] [--version] DEVICE\nsgopcodes [-a] [-c] [-e] [-H] [-m] [-M] [-n] [-o=OP] [-p=DT] [-q]  [-R]  [-s=SA]  [-t]  [-u]\n[-v] [-V] [-?]  DEVICE",
    "sections": {
        "NAME": {
            "content": "sgopcodes - report supported SCSI commands or task management functions\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "sgopcodes  [--alpha]  [--compact]  [--enumerate] [--help] [--hex] [--mask] [--mlu] [--no-in‐\nquiry] [--opcode=OP[,SA]] [--pdt=DT] [--raw] [--rctd] [--repd] [--sa=SA] [--tmf] [--unsorted]\n[--verbose] [--version] DEVICE\n\nsgopcodes [-a] [-c] [-e] [-H] [-m] [-M] [-n] [-o=OP] [-p=DT] [-q]  [-R]  [-s=SA]  [-t]  [-u]\n[-v] [-V] [-?]  DEVICE\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This utility sends a SCSI REPORT SUPPORTED OPERATION CODES or a REPORT SUPPORTED TASK MANAGE‐\nMENT  FUNCTIONS command to the DEVICE and then outputs the response. The default action is to\nreport supported operation codes. In this mode it will either list all supported commands  or\ngive detailed information on a specific command identified by the --opcode=OP option (perhaps\nwith additional information from the --sa=SA option).\n\nThe  name  of  a SCSI command depends on its peripheral device type (e.g. a disk). The REPORT\nSUPPORTED OPERATION CODES and REPORT SUPPORTED TASK MANAGEMENT  FUNCTIONS  commands  are  not\nsupported  in the MMC command set for CD and DVD devices. This utility does an INQUIRY to ob‐\ntain the peripheral device type and prints out the vendor, product and revision strings.\n\nA similar facility to query supported operation codes previously was available via the  CmdDt\nbit  in the SCSI INQUIRY command (see sginq(8)). However that facility was made obsolete and\nreplaced by the REPORT SUPPORTED OPERATION CODES command in SPC-3 (revision 4) during  Febru‐\nary 2002.\n\nThis utility supports two command line syntaxes, the preferred one is shown first in the syn‐\nopsis  and explained in this section. A later section on the old command line syntax outlines\nthe second group of options.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Arguments to long options are mandatory for short options as well.\n",
            "subsections": [
                {
                    "name": "-a --alpha",
                    "content": "when all supported commands are being listed there is no requirement  for  the  device\nserver  (i.e.  the DEVICE) to sort the list of commands. When this option is given the\nlist of supported commands is sorted by name (alphabetically). When  this  option  and\nthe  --unsorted  option  are  both  not given then the list of supported commands is\nsorted numerically (first by operation code and then by service action).\n",
                    "flag": "-a",
                    "long": "--alpha"
                },
                {
                    "name": "-c --compact",
                    "content": "some command names, especially those associated with some service actions, are getting\nlonger. This may cause line wrap in the one line per command mode on  some  terminals.\nWhen  this  option  is  given the opcode and service action fields are combined into a\nsingle field with the service action, prefixed by a comma shown directly after the op‐\ncode. If there is no service action associated with the command, then  the  comma  and\nthe  service  action  are  not shown after the opcode. The CDB size field is not shown\nwhen this option is given.\n",
                    "flag": "-c",
                    "long": "--compact"
                },
                {
                    "name": "-e --enumerate",
                    "content": "this option prints the name of the SCSI command based on the given opcode,  peripheral\ndevice  type  and  optionally the service action. If given, DEVICE is ignored. The op‐\ncode, peripheral device type and service action default to zero if not given. Thus  if\nthis option is the only option given then \"Test Unit ready\" is output since its opcode\nis  0,  it has no service action and it is common to all peripheral device types since\nit is defined in the SCSI Primary Commands (SPC) standard(s).\n",
                    "flag": "-e",
                    "long": "--enumerate"
                },
                {
                    "name": "-h --help",
                    "content": "outputs the usage message summarizing command line options then exits. Ignores  DEVICE\nif given.\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-H --hex",
                    "content": "outputs the response in ASCII hexadecimal to stdout.\n",
                    "flag": "-H",
                    "long": "--hex"
                },
                {
                    "name": "-m --mask",
                    "content": "additionally  prints  out  the  cdb  mask in hex. So a 12 byte cdb will have a 12 byte\nhexadecimal mask. If the hexadecimal is expanded (mentally) to binary then a \"1\" means\nthe corresponding position in the cdb may be set. And \"0\" means the corresponding  po‐\nsition  in the cdb must not be set. For \"0\" mask positions that a user tries to set in\na cdb, the device may either ignore it or report an error, typically with a sense  key\nof \"illegal request\".\n",
                    "flag": "-m",
                    "long": "--mask"
                },
                {
                    "name": "-M --mlu",
                    "content": "additionally prints out an indication (0 or 1) whether the command effects all logical\nunits  in  the  containing target. MLU (Multiple Logical Units) is a bit in the REPORT\nSUPPORTED OPERATION CODES response introduced by proposal 18-045r1  (and  possibly  in\nspc5r20).  Without the option, the default output format which lists all opcodes, does\nnot include a MLU indication.\n",
                    "flag": "-M",
                    "long": "--mlu"
                },
                {
                    "name": "-n --no-inquiry",
                    "content": "Prior to calling a SCSI REPORT SUPPORTED OPERATION CODES or a  REPORT  SUPPORTED  TASK\nMANAGEMENT  FUNCTIONS  command,  a SCSI INQUIRY command is performed. The reason is to\ndetermine the peripheral device type (pdt) of the DEVICE as this is helpful in  trans‐\nlating  operation codes to the command names. By default this utility prints a summary\nof INQUIRY command response on stdout. If this option (or the --raw option)  is  given\nthen that summary is not printed on stdout.\n",
                    "flag": "-n",
                    "long": "--no-inquiry"
                },
                {
                    "name": "-O --old",
                    "content": "Switch to older style options. Please use as first option.\n",
                    "flag": "-O",
                    "long": "--old"
                },
                {
                    "name": "-o --opcode",
                    "content": "the  DEVICE  will be queried for the given operation code (i.e. the OP value) which is\nthe first byte of a SCSI command. Optionally, if a SA value is given, it will be  used\nas  that  SCSI command's service action. Note that OP and OP,0 are not the same thing,\nas SCSI does allow the service action to be 0 (but it is not comman). OP  and  SA  are\ndecimal  unless  prefixed  by  \"0x\"  or they have a trailing \"h\".  OP should be in the\nrange 0 to 255 (0xff) inclusive. SA should be in the range 0 to 65535 (0xffff)  inclu‐\nsive.  When this option is not given then all available SCSI commands supported by the\nDEVICE are listed.\n",
                    "flag": "-o",
                    "long": "--opcode"
                },
                {
                    "name": "-p --pdt",
                    "content": "where DT is the peripheral device type. This is used together with the --enumerate  to\ndifferentiate when a command opcode (and perhaps service action) is shared by multiple\ndevice types.\nThis option may also be used with the --no-inquiry option to suppress this utility do‐\ning  an INQUIRY command since the main reason for doing that is to find the peripheral\ndevice type of the DEVICE.\n",
                    "flag": "-p",
                    "long": "--pdt"
                },
                {
                    "name": "-r --raw",
                    "content": "output the response in binary to stdout. Error messages and warnings, if any, are sent\nto stderr.\n",
                    "flag": "-r",
                    "long": "--raw"
                },
                {
                    "name": "-R --rctd",
                    "content": "set report command timeout descriptor (RCTD) bit in the cdb. The response may  or  may\nnot  contain  command  timeout descriptors. If available they are output. If supported\nthere are two values: a nominal command timeout and  a  recommended  command  timeout.\nBoth  have  units  of  seconds. A value of zero means that no timeout is indicated and\nthis is shown in the corresponding decoded output as \"-\".\n",
                    "flag": "-R",
                    "long": "--rctd"
                },
                {
                    "name": "-q --repd",
                    "content": "set read extended parameter data (REPD) bit in the report  task  management  functions\ncdb. 16 bytes rather than the default 4 bytes expected in the response. This was added\nin SPC-4 (revision 26).\n",
                    "flag": "-q",
                    "long": "--repd"
                },
                {
                    "name": "-s --sa",
                    "content": "the  DEVICE  will  be queried for a command with the given service action (i.e. the SA\nvalue). Used in conjunction with the --opcode=OP option. If this option is not  given,\n--opcode=OP  is  given  and  the command in question does have a service action then a\nvalue of 0 will be assumed. SA is decimal and expected to be in the range 0  to  65535\n(0xffff) inclusive.\n",
                    "flag": "-s",
                    "long": "--sa"
                },
                {
                    "name": "-t --tmf",
                    "content": "list  supported task management functions. This is done with the SCSI REPORT SUPPORTED\nTASK MANAGEMENT FUNCTIONS command.  When this option  is  chosen  the  --alpha,  --op‐\ncode=OP, --rctd, --sa=SA and --unsorted options are ignored.\n",
                    "flag": "-t",
                    "long": "--tmf"
                },
                {
                    "name": "-u --unsorted",
                    "content": "when  all  supported  commands are being listed there is no requirement for the device\nserver (i.e. the DEVICE) to sort the list of commands. When this option is  given  the\nlist  of  supported  commands is in the order given by the DEVICE. When this option is\nnot given the supported commands are sorted numerically (first by operation  code  and\nthen by service action).\n",
                    "flag": "-u",
                    "long": "--unsorted"
                },
                {
                    "name": "-v --verbose",
                    "content": "increase level of verbosity. Can be used multiple times.\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "-V --version",
                    "content": "print out version string then exit.\n",
                    "flag": "-V",
                    "long": "--version"
                }
            ]
        },
        "NOTES": {
            "content": "As  of  SPC-5  revision 8 the recognized task management functions are: abort set, abort task\nset, clear ACA, clear task set, logical unit reset, query  task,  query  asynchronous  event,\nquery  task set, and IT nexus reset.  In SPC-4 revision 26 target reset and wakeup task man‐\nagement functions were made obsolete.\n\nIn the 2.4 series of Linux kernels the DEVICE must be a SCSI generic (sg) device. In the  2.6\nseries  block  devices  (e.g.  SCSI  disks and DVD drives) can also be specified. For example\n\"sgopcodes /dev/sda\" will work in the 2.6 series kernels.\n",
            "subsections": []
        },
        "EXIT STATUS": {
            "content": "The exit status of sgopcodes is 0 when it is successful. Otherwise see the sg3utils(8)  man\npage.\n",
            "subsections": []
        },
        "OLDER COMMAND LINE OPTIONS": {
            "content": "The  options  in  this section were the only ones available prior to sg3utils version 1.23 .\nSince then this utility defaults to the newer command line options which can be overridden by\nusing --old (or -O) as the first option. See the ENVIRONMENT VARIABLES  section  for  another\nway to force the use of these older command line options.\n",
            "subsections": [
                {
                    "name": "-a",
                    "content": "",
                    "flag": "-a"
                },
                {
                    "name": "-c",
                    "content": "",
                    "flag": "-c"
                },
                {
                    "name": "-e",
                    "content": "",
                    "flag": "-e"
                },
                {
                    "name": "-H",
                    "content": "",
                    "flag": "-H"
                },
                {
                    "name": "-m",
                    "content": "",
                    "flag": "-m"
                },
                {
                    "name": "-n",
                    "content": "",
                    "flag": "-n"
                },
                {
                    "name": "-N --new",
                    "content": "Switch to the newer style options.\n",
                    "flag": "-N",
                    "long": "--new"
                },
                {
                    "name": "-o",
                    "content": "byte of a SCSI command. OP is hexadecimal and expected to be in the range 0 to ff  in‐\nclusive.   When this option is not given then all available SCSI commands supported by\nthe DEVICE are listed.\n",
                    "flag": "-o"
                },
                {
                    "name": "-p",
                    "content": "",
                    "flag": "-p"
                },
                {
                    "name": "-q",
                    "content": "--repd in main description.\n",
                    "flag": "-q"
                },
                {
                    "name": "-R",
                    "content": "main description.\n",
                    "flag": "-R"
                },
                {
                    "name": "-s",
                    "content": "in conjunction with the -o=OP option. If this option is not given, -o=OP is given  and\nthe  command in question does have a service action then a value of 0 will be assumed.\nSA is hexadecimal and expected to be in the range 0 to ffff inclusive.\n",
                    "flag": "-s"
                },
                {
                    "name": "-t",
                    "content": "",
                    "flag": "-t"
                },
                {
                    "name": "-u",
                    "content": "in main description.\n",
                    "flag": "-u"
                },
                {
                    "name": "-v",
                    "content": "",
                    "flag": "-v"
                },
                {
                    "name": "-V",
                    "content": "-?     output usage message. Ignore all other parameters.\n",
                    "flag": "-V"
                }
            ]
        },
        "EXAMPLES": {
            "content": "The  examples  in  this  page use Linux device names. For suitable device names in other sup‐\nported Operating Systems see the sg3utils(8) man page.\n\nTo see the information about a specific command give its operation code to  the  '--op='  op‐\ntion. A command line invocation is shown first followed by a typical response:\n\n# sgopcodes --op=93h /dev/sdb\n\nOpcode=0x93\nCommandname: Write same(16)\nCommand supported [conforming to SCSI standard]\nUsage data: 93 e2 00 00 00 00 ff ff ff ff 00 00 ff ff 00 00\n\nThe next example shows the supported task management functions:\n\n# sgopcodes --tmf -n /dev/sdb\n\nTask Management Functions supported by device:\nAbort task\nAbort task set\nClear ACA\nClear task set\nLogical unit reset\nQuery task\n\nEnumerate can be used to look up a SCSI command name in the absence of a device that supports\nthat command. The opcode and service action (if required) should be supplied:\n\n# sgopcodes --enumerate --op=0x9b,0xa\n\nSCSI command:\nRead buffer(16), read data from echo buffer\n",
            "subsections": []
        },
        "ENVIRONMENT VARIABLES": {
            "content": "Since  sg3utils  version 1.23 the environment variable SG3UTILSOLDOPTS can be given. When\nit is present this utility will expect the older command line options.  So  the  presence  of\nthis  environment variable is equivalent to using --old (or -O) as the first command line op‐\ntion.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Written by Douglas Gilbert\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "Report bugs to <dgilbert at interlog dot com>.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright © 2004-2021 Douglas Gilbert\nThis software is distributed under the GPL version 2. There is NO warranty; not even for MER‐\nCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "",
            "subsections": [
                {
                    "name": "sg_inq(sg3_utils)",
                    "content": "sg3utils-1.46                               March 2020                                SGOPCODES(8)"
                }
            ]
        }
    },
    "summary": "sgopcodes - report supported SCSI commands or task management functions",
    "flags": [
        {
            "flag": "-a",
            "long": "--alpha",
            "arg": null,
            "description": "when all supported commands are being listed there is no requirement for the device server (i.e. the DEVICE) to sort the list of commands. When this option is given the list of supported commands is sorted by name (alphabetically). When this option and the --unsorted option are both not given then the list of supported commands is sorted numerically (first by operation code and then by service action)."
        },
        {
            "flag": "-c",
            "long": "--compact",
            "arg": null,
            "description": "some command names, especially those associated with some service actions, are getting longer. This may cause line wrap in the one line per command mode on some terminals. When this option is given the opcode and service action fields are combined into a single field with the service action, prefixed by a comma shown directly after the op‐ code. If there is no service action associated with the command, then the comma and the service action are not shown after the opcode. The CDB size field is not shown when this option is given."
        },
        {
            "flag": "-e",
            "long": "--enumerate",
            "arg": null,
            "description": "this option prints the name of the SCSI command based on the given opcode, peripheral device type and optionally the service action. If given, DEVICE is ignored. The op‐ code, peripheral device type and service action default to zero if not given. Thus if this option is the only option given then \"Test Unit ready\" is output since its opcode is 0, it has no service action and it is common to all peripheral device types since it is defined in the SCSI Primary Commands (SPC) standard(s)."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "outputs the usage message summarizing command line options then exits. Ignores DEVICE if given."
        },
        {
            "flag": "-H",
            "long": "--hex",
            "arg": null,
            "description": "outputs the response in ASCII hexadecimal to stdout."
        },
        {
            "flag": "-m",
            "long": "--mask",
            "arg": null,
            "description": "additionally prints out the cdb mask in hex. So a 12 byte cdb will have a 12 byte hexadecimal mask. If the hexadecimal is expanded (mentally) to binary then a \"1\" means the corresponding position in the cdb may be set. And \"0\" means the corresponding po‐ sition in the cdb must not be set. For \"0\" mask positions that a user tries to set in a cdb, the device may either ignore it or report an error, typically with a sense key of \"illegal request\"."
        },
        {
            "flag": "-M",
            "long": "--mlu",
            "arg": null,
            "description": "additionally prints out an indication (0 or 1) whether the command effects all logical units in the containing target. MLU (Multiple Logical Units) is a bit in the REPORT SUPPORTED OPERATION CODES response introduced by proposal 18-045r1 (and possibly in spc5r20). Without the option, the default output format which lists all opcodes, does not include a MLU indication."
        },
        {
            "flag": "-n",
            "long": "--no-inquiry",
            "arg": null,
            "description": "Prior to calling a SCSI REPORT SUPPORTED OPERATION CODES or a REPORT SUPPORTED TASK MANAGEMENT FUNCTIONS command, a SCSI INQUIRY command is performed. The reason is to determine the peripheral device type (pdt) of the DEVICE as this is helpful in trans‐ lating operation codes to the command names. By default this utility prints a summary of INQUIRY command response on stdout. If this option (or the --raw option) is given then that summary is not printed on stdout."
        },
        {
            "flag": "-O",
            "long": "--old",
            "arg": null,
            "description": "Switch to older style options. Please use as first option."
        },
        {
            "flag": "-o",
            "long": "--opcode",
            "arg": null,
            "description": "the DEVICE will be queried for the given operation code (i.e. the OP value) which is the first byte of a SCSI command. Optionally, if a SA value is given, it will be used as that SCSI command's service action. Note that OP and OP,0 are not the same thing, as SCSI does allow the service action to be 0 (but it is not comman). OP and SA are decimal unless prefixed by \"0x\" or they have a trailing \"h\". OP should be in the range 0 to 255 (0xff) inclusive. SA should be in the range 0 to 65535 (0xffff) inclu‐ sive. When this option is not given then all available SCSI commands supported by the DEVICE are listed."
        },
        {
            "flag": "-p",
            "long": "--pdt",
            "arg": null,
            "description": "where DT is the peripheral device type. This is used together with the --enumerate to differentiate when a command opcode (and perhaps service action) is shared by multiple device types. This option may also be used with the --no-inquiry option to suppress this utility do‐ ing an INQUIRY command since the main reason for doing that is to find the peripheral device type of the DEVICE."
        },
        {
            "flag": "-r",
            "long": "--raw",
            "arg": null,
            "description": "output the response in binary to stdout. Error messages and warnings, if any, are sent to stderr."
        },
        {
            "flag": "-R",
            "long": "--rctd",
            "arg": null,
            "description": "set report command timeout descriptor (RCTD) bit in the cdb. The response may or may not contain command timeout descriptors. If available they are output. If supported there are two values: a nominal command timeout and a recommended command timeout. Both have units of seconds. A value of zero means that no timeout is indicated and this is shown in the corresponding decoded output as \"-\"."
        },
        {
            "flag": "-q",
            "long": "--repd",
            "arg": null,
            "description": "set read extended parameter data (REPD) bit in the report task management functions cdb. 16 bytes rather than the default 4 bytes expected in the response. This was added in SPC-4 (revision 26)."
        },
        {
            "flag": "-s",
            "long": "--sa",
            "arg": null,
            "description": "the DEVICE will be queried for a command with the given service action (i.e. the SA value). Used in conjunction with the --opcode=OP option. If this option is not given, --opcode=OP is given and the command in question does have a service action then a value of 0 will be assumed. SA is decimal and expected to be in the range 0 to 65535 (0xffff) inclusive."
        },
        {
            "flag": "-t",
            "long": "--tmf",
            "arg": null,
            "description": "list supported task management functions. This is done with the SCSI REPORT SUPPORTED TASK MANAGEMENT FUNCTIONS command. When this option is chosen the --alpha, --op‐ code=OP, --rctd, --sa=SA and --unsorted options are ignored."
        },
        {
            "flag": "-u",
            "long": "--unsorted",
            "arg": null,
            "description": "when all supported commands are being listed there is no requirement for the device server (i.e. the DEVICE) to sort the list of commands. When this option is given the list of supported commands is in the order given by the DEVICE. When this option is not given the supported commands are sorted numerically (first by operation code and then by service action)."
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "increase level of verbosity. Can be used multiple times."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "print out version string then exit."
        }
    ],
    "examples": [
        "The  examples  in  this  page use Linux device names. For suitable device names in other sup‐",
        "ported Operating Systems see the sg3utils(8) man page.",
        "To see the information about a specific command give its operation code to  the  '--op='  op‐",
        "tion. A command line invocation is shown first followed by a typical response:",
        "# sgopcodes --op=93h /dev/sdb",
        "Opcode=0x93",
        "Commandname: Write same(16)",
        "Command supported [conforming to SCSI standard]",
        "Usage data: 93 e2 00 00 00 00 ff ff ff ff 00 00 ff ff 00 00",
        "The next example shows the supported task management functions:",
        "# sgopcodes --tmf -n /dev/sdb",
        "Task Management Functions supported by device:",
        "Abort task",
        "Abort task set",
        "Clear ACA",
        "Clear task set",
        "Logical unit reset",
        "Query task",
        "Enumerate can be used to look up a SCSI command name in the absence of a device that supports",
        "that command. The opcode and service action (if required) should be supplied:",
        "# sgopcodes --enumerate --op=0x9b,0xa",
        "SCSI command:",
        "Read buffer(16), read data from echo buffer"
    ],
    "see_also": []
}