{
    "mode": "man",
    "parameter": "sg_stpg",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/sg_stpg/8/json",
    "generated": "2026-06-14T13:16:00Z",
    "synopsis": "sgstpg   [--active]   [--help]   [--hex]   [--offline]   [--optimized]  [--raw]  [--standby]\n[--state=S,S...] [--tp=P,P...] [--unavailable] [--verbose] [--version] DEVICE",
    "sections": {
        "NAME": {
            "content": "sgstpg - send SCSI SET TARGET PORT GROUPS command\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "sgstpg   [--active]   [--help]   [--hex]   [--offline]   [--optimized]  [--raw]  [--standby]\n[--state=S,S...] [--tp=P,P...] [--unavailable] [--verbose] [--version] DEVICE\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Send a SCSI SET TARGET PORT GROUPS command to DEVICE. This utility has  different  modes  de‐\npending on whether the --tp= option is given.\n\nIf --tp= is given then the SET TARGET PORT GROUPS command parameter block is built with a de‐\nscriptor for each element in the list given to --tp=.  The  corresponding  asymmetric  access\nstate  value is either taken from the --state= list or, if that is not given, from one of the\nexplicit state options (e.g. --unavailable), used repeatedly if required.\n\nIf --tp= is not given then a sequence of SCSI commands are sent to the DEVICE leading  up  to\nthe  SET TARGET PORT GROUPS command. First an INQUIRY is sent to fetch the device identifica‐\ntion VPD page to find the (primary) target port group associated with DEVICE. Then  a  REPORT\nTARGET  PORT  GROUPS  command is issued to find the current state and whether a transition to\nthe requested state is supported. If so the SET TARGET PORT GROUPS command is sent.\n\nTarget port group access is described in SPC-4 found at www.t10.org in sections 5.8 and  5.16\n(in rev 36e dated 2012/8/24). The SET TARGET PORT GROUPS command is also described in section\n6.45 of that document.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Arguments to long options are mandatory for short options as well.  The options are  arranged\nin alphabetical order based on the long option name.\n",
            "subsections": [
                {
                    "name": "-a --active",
                    "content": "set active/non-optimized state.\n",
                    "flag": "-a",
                    "long": "--active"
                },
                {
                    "name": "-h --help",
                    "content": "output the usage message then exit.\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-H --hex",
                    "content": "output response to the REPORT TARGET PORT GROUPS command in hex then exit.\n",
                    "flag": "-H",
                    "long": "--hex"
                },
                {
                    "name": "-O -l --offline",
                    "content": "set  offline state. This is the appropriate state to set a target port to prior to re‐\nmoving the device.  Note that a relative target port identifier should be  given  with\nthis state (rather than a target port group identifier that all other states take).\n",
                    "flag": "-l",
                    "long": "--offline"
                },
                {
                    "name": "-o --optimized",
                    "content": "set  active/optimized  state. If no other state options or --tp= option are given then\nactive/optimized is the default state.\n",
                    "flag": "-o",
                    "long": "--optimized"
                },
                {
                    "name": "-r --raw",
                    "content": "output response to the REPORT TARGET PORT GROUPS command  in  binary  to  stdout  then\nexit.\n",
                    "flag": "-r",
                    "long": "--raw"
                },
                {
                    "name": "-s --standby",
                    "content": "set  standby  state.  Port  group shall accept those commands listed for \"unavailable\"\nstate plus LOG SELECT/SENSE, MODE SELECT/SENSE, RECEIVE DIAGNOSTIC RESULTS, SEND DIAG‐\nNOSTIC, PERSISTENT RESERVE IN/OUT commands.\n",
                    "flag": "-s",
                    "long": "--standby"
                },
                {
                    "name": "-S --state",
                    "content": "specifies  a  comma separated list (one element of more) of states. Either a number or\nan abbreviation can be given. A number is assumed to be a decimal number unless it  is\nprefixed  by  \"0x\" or has a trailing \"h\" in which case a hexadecimal value is assumed.\nOnly the values 0, 1, 2, 3 or 14 are accepted. The accepted  abbreviations  are  \"an\",\n\"ao\",  \"o\",  \"s\" or \"u\"; which represent active/non-optimized(1), active/optimized(0),\noffline(14), standby(2) or unavailable(3) respectively.\n",
                    "flag": "-S",
                    "long": "--state"
                },
                {
                    "name": "-t --tp",
                    "content": "specifies a comma separated list (one element of more). Each elements is either a tar‐\nget  port group identifier (when the corresponding state is other than \"offline\") or a\nrelative target port identifier (when the corresponding state is \"offline\"). Each ele‐\nment is assumed to be a decimal number unless it is prefixed by \"0x\" or has a trailing\n\"h\" in which case a hexadecimal value is assumed.\n",
                    "flag": "-t",
                    "long": "--tp"
                },
                {
                    "name": "-u --unavailable",
                    "content": "set unavailable state. Port group shall only accept INQUIRY, REPORT  LUNS,  REPORT/SET\nTARGET PORT GROUPS, REQUEST SENSE and READ/WRITE BUFFER commands.\n",
                    "flag": "-u",
                    "long": "--unavailable"
                },
                {
                    "name": "-v --verbose",
                    "content": "increase the level of verbosity, (i.e. debug output).\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "-V --version",
                    "content": "print the version string and then exit.\n",
                    "flag": "-V",
                    "long": "--version"
                }
            ]
        },
        "NOTES": {
            "content": "The  SET TARGET PORT GROUPS command should be supported whenever the TPGS value in a standard\nINQUIRY response is 2 or 3. [View with sginq utility.]\n\nNotice that the offline state is termed as a \"secondary target port asymmetric access  state\"\nand  takes  a  relative  target port identifier (i.e.  acts on a single target port). All the\nother states are termed as \"primary target port asymmetric access states\" and  each  takes  a\ntarget port group identifier (i.e. acts on one or more target ports).\n\nWhen  --tp= is given then the same number of elements should be given to the --state= option.\nIf more than one list element is given to --tp= and an equal  number  of  elements  is  not\ngiven to the --state= option, then if only one state is specified then it is repeated.\n",
            "subsections": []
        },
        "EXIT STATUS": {
            "content": "The  exit  status  of  sgstpg is 0 when it is successful. Otherwise see the sg3utils(8) man\npage.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Written by Douglas Gilbert.\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "Report bugs to <dgilbert at interlog dot com>.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright © 2007-2014 Hannes Reinecke, Christophe Varoqui and Douglas Gilbert\nThis software is distributed under a FreeBSD license. There is NO warranty; not even for MER‐\nCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "sginq, sgrtpg (sg3utils)\n\n\n\nsg3utils-1.38                              January 2014                                  SGSTPG(8)",
            "subsections": []
        }
    },
    "summary": "sgstpg - send SCSI SET TARGET PORT GROUPS command",
    "flags": [
        {
            "flag": "-a",
            "long": "--active",
            "arg": null,
            "description": "set active/non-optimized state."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "output the usage message then exit."
        },
        {
            "flag": "-H",
            "long": "--hex",
            "arg": null,
            "description": "output response to the REPORT TARGET PORT GROUPS command in hex then exit."
        },
        {
            "flag": "-l",
            "long": "--offline",
            "arg": null,
            "description": "set offline state. This is the appropriate state to set a target port to prior to re‐ moving the device. Note that a relative target port identifier should be given with this state (rather than a target port group identifier that all other states take)."
        },
        {
            "flag": "-o",
            "long": "--optimized",
            "arg": null,
            "description": "set active/optimized state. If no other state options or --tp= option are given then active/optimized is the default state."
        },
        {
            "flag": "-r",
            "long": "--raw",
            "arg": null,
            "description": "output response to the REPORT TARGET PORT GROUPS command in binary to stdout then exit."
        },
        {
            "flag": "-s",
            "long": "--standby",
            "arg": null,
            "description": "set standby state. Port group shall accept those commands listed for \"unavailable\" state plus LOG SELECT/SENSE, MODE SELECT/SENSE, RECEIVE DIAGNOSTIC RESULTS, SEND DIAG‐ NOSTIC, PERSISTENT RESERVE IN/OUT commands."
        },
        {
            "flag": "-S",
            "long": "--state",
            "arg": null,
            "description": "specifies a comma separated list (one element of more) of states. Either a number or an abbreviation can be given. A number is assumed to be a decimal number unless it is prefixed by \"0x\" or has a trailing \"h\" in which case a hexadecimal value is assumed. Only the values 0, 1, 2, 3 or 14 are accepted. The accepted abbreviations are \"an\", \"ao\", \"o\", \"s\" or \"u\"; which represent active/non-optimized(1), active/optimized(0), offline(14), standby(2) or unavailable(3) respectively."
        },
        {
            "flag": "-t",
            "long": "--tp",
            "arg": null,
            "description": "specifies a comma separated list (one element of more). Each elements is either a tar‐ get port group identifier (when the corresponding state is other than \"offline\") or a relative target port identifier (when the corresponding state is \"offline\"). Each ele‐ ment is assumed to be a decimal number unless it is prefixed by \"0x\" or has a trailing \"h\" in which case a hexadecimal value is assumed."
        },
        {
            "flag": "-u",
            "long": "--unavailable",
            "arg": null,
            "description": "set unavailable state. Port group shall only accept INQUIRY, REPORT LUNS, REPORT/SET TARGET PORT GROUPS, REQUEST SENSE and READ/WRITE BUFFER commands."
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "increase the level of verbosity, (i.e. debug output)."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "print the version string and then exit."
        }
    ],
    "examples": [],
    "see_also": []
}