Unit content
Entropy changes of a system, surroundings and universe
The second law predicts spontaneity by considering the entropy change of the universe, meaning the chosen system together with its surroundings:
$$\boxed{\Delta S_{\mathrm{univ}}=\Delta S_{\mathrm{sys}}+\Delta S_{\mathrm{surr}}}.$$
A process is thermodynamically spontaneous in the stated direction when
$$\Delta S_{\mathrm{univ}}>0.$$
At equilibrium,
$$\Delta S_{\mathrm{univ}}=0,$$
and a proposed direction with $\Delta S_{\mathrm{univ}}<0$ is nonspontaneous; the reverse direction is favored instead.
The system entropy need not increase by itself. A system can become more ordered or lose entropy while the surroundings gain even more entropy, giving a positive total change.
Entropy change of a thermal reservoir
If a large surrounding reservoir remains essentially at a constant absolute temperature $T$ while receiving heat $q_{\mathrm{surr}}$, its entropy change is
$$\boxed{\Delta S_{\mathrm{surr}}=\frac{q_{\mathrm{surr}}}{T}}.$$
Energy conservation gives
$$q_{\mathrm{surr}}=-q_{\mathrm{sys}}.$$
Example: heat flowing from hot to cold
Suppose $100,\mathrm J$ of heat leaves a reservoir at $400,\mathrm K$ and enters one at $300,\mathrm K$.
For the hot reservoir,
$$\Delta S_{\mathrm{hot}}=\frac{-100}{400}=-0.250,\mathrm{J/K}.$$
For the cold reservoir,
$$\Delta S_{\mathrm{cold}}=\frac{+100}{300}=+0.333,\mathrm{J/K}.$$
Therefore
$$\Delta S_{\mathrm{univ}}=-0.250+0.333=+0.083,\mathrm{J/K}>0.$$
Heat transfer from hot to cold is therefore spontaneous. Reversing the same transfer would give a negative entropy change of the universe and cannot occur spontaneously without some additional change elsewhere.
The second law is thus a statement about the combined entropy accounting of system and surroundings, not a rule that every individual subsystem must always increase its entropy.