As one of the most important aspects of thermodynamics, entropy is specifically that thermodynamic quantity that represents lack of availability of thermal energy of that system. This energy is specifically required for conversion to that and interprets a certain degree of randomness in the system. If there is a change in the surroundings, there is entropy change, which is specifically driven by heat flow within the system.
There are 2 processes in this regard: Reversible and Irreversible processes.
In either case, Clausius theorem is to be applied and it is from here that both the paths are reversed.
Here is a detailed explanation of this process.
In fig 8.5