# man > SG_STPG(8)

[SG_STPG(8)](https://www.chedong.com/phpMan.php/man/SGSTPG/8/markdown)                                    SG3_UTILS                                   [SG_STPG(8)](https://www.chedong.com/phpMan.php/man/SGSTPG/8/markdown)



## NAME
       sg_stpg - send SCSI SET TARGET PORT GROUPS command

## SYNOPSIS
       **sg**___**stpg**   [_--active_]   [_--help_]   [_--hex_]   [_--offline_]   [_--optimized_]  [_--raw_]  [_--standby_]
       [_--state=S,S..._] [_--tp=P,P..._] [_--unavailable_] [_--verbose_] [_--version_] _DEVICE_

## DESCRIPTION
       Send a SCSI SET TARGET PORT GROUPS command to _DEVICE_. This utility has  different  modes  de‐
       pending on whether the _--tp=_ option is given.

       If _--tp=_ is given then the SET TARGET PORT GROUPS command parameter block is built with a de‐
       scriptor for each element in the list given to _--tp=_.  The  corresponding  asymmetric  access
       state  value is either taken from the _--state=_ list or, if that is not given, from one of the
       explicit state options (e.g. _--unavailable_), used repeatedly if required.

       If _--tp=_ is not given then a sequence of SCSI commands are sent to the _DEVICE_ leading  up  to
       the  SET TARGET PORT GROUPS command. First an INQUIRY is sent to fetch the device identifica‐
       tion VPD page to find the (primary) target port group associated with _DEVICE_. Then  a  REPORT
       TARGET  PORT  GROUPS  command is issued to find the current state and whether a transition to
       the requested state is supported. If so the SET TARGET PORT GROUPS command is sent.

       Target port group access is described in SPC-4 found at www.t10.org in sections 5.8 and  5.16
       (in rev 36e dated 2012/8/24). The SET TARGET PORT GROUPS command is also described in section
       6.45 of that document.

## OPTIONS
       Arguments to long options are mandatory for short options as well.  The options are  arranged
       in alphabetical order based on the long option name.

### -a --active
              set active/non-optimized state.

### -h --help
              output the usage message then exit.

### -H --hex
              output response to the REPORT TARGET PORT GROUPS command in hex then exit.

### -O -l --offline
              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).

### -o --optimized
              set  active/optimized  state. If no other state options or _--tp=_ option are given then
              active/optimized is the default state.

### -r --raw
              output response to the REPORT TARGET PORT GROUPS command  in  binary  to  stdout  then
              exit.

### -s --standby
              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.

### -S --state
              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)](https://www.chedong.com/phpMan.php/man/non-optimized/1/markdown), active/[optimized(0)](https://www.chedong.com/phpMan.php/man/optimized/0/markdown),
              [offline(14)](https://www.chedong.com/phpMan.php/man/offline/14/markdown), [standby(2)](https://www.chedong.com/phpMan.php/man/standby/2/markdown) or [unavailable(3)](https://www.chedong.com/phpMan.php/man/unavailable/3/markdown) respectively.

### -t --tp
              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.

### -u --unavailable
              set unavailable state. Port group shall only accept INQUIRY, REPORT  LUNS,  REPORT/SET
              TARGET PORT GROUPS, REQUEST SENSE and READ/WRITE BUFFER commands.

### -v --verbose
              increase the level of verbosity, (i.e. debug output).

### -V --version
              print the version string and then exit.

## NOTES
       The  SET TARGET PORT GROUPS command should be supported whenever the TPGS value in a standard
       INQUIRY response is 2 or 3. [View with sg_inq utility.]

       Notice that the offline state is termed as a "secondary target port asymmetric access  state"
       and  takes  a  relative  target port identifier (i.e.  acts on a single target port). All the
       other states are termed as "primary target port asymmetric access states" and  each  takes  a
       target port group identifier (i.e. acts on one or more target ports).

       When  _--tp=_ is given then the same number of elements should be given to the _--state=_ option.
       If more than one list element is given to _--tp=_ and an equal  number  of  elements  is  _not_
       given to the _--state=_ option, then if only one state is specified then it is repeated.

## EXIT STATUS
       The  exit  status  of  sg_stpg is 0 when it is successful. Otherwise see the [sg3_utils(8)](https://www.chedong.com/phpMan.php/man/sg3utils/8/markdown) man
       page.

## AUTHORS
       Written by Douglas Gilbert.

## REPORTING BUGS
       Report bugs to <dgilbert at interlog dot com>.

## COPYRIGHT
       Copyright © 2007-2014 Hannes Reinecke, Christophe Varoqui and Douglas Gilbert
       This software is distributed under a FreeBSD license. There is NO warranty; not even for MER‐
       CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

## SEE ALSO
       **sg**___**inq,** **sg**___**rtpg** **(sg3**___**utils)**



sg3_utils-1.38                              January 2014                                  [SG_STPG(8)](https://www.chedong.com/phpMan.php/man/SGSTPG/8/markdown)
