Wikipedia has a nice article on the topic of oxidation state. It quotes the IUPAC definition:
IUPAC: Oxidation state of an atom is the charge of this atom after ionic approximation of its heteronuclear bonds [...]
For sulfur in particular, if there are no unpaired electrons, no bonds to another sulfur (i.e. all heteronuclear bonds) and sulfur has an octet, the oxidation state of sulfur will come out as an even number. The range is -2 (all electrons in octet counted towards sulfur, i.e. $\ce{H2S}$) to +6 (no electrons in octet counted towards sulfur, i.e. $\ce{H2SO4}$). For each heteronuclear bond, the electrons associated with it are either all counted toward the sulfur atom, or none of them are.
[OP] The question arises from trying to get where does the values of −2, 0, +2, +4 and +6 from the electron configuration.
The oxidation states are listed by wikipedia as the major ones (the ones in bold, see below), but others such as +1 (e.g. $\ce{H2S2}$, dihydrogen disulfide) are also possible.
