Using molecular simulation, we analyze the capillary condensation and evaporation processes. For this purpose, we define the entropy of the adsorbed fluid as a reaction coordinate, and determine the free energy associated with both processes. We find capillary condensation to proceed through the nucleation of a liquid bridge across the nanopore, followed by its expansion throughout the pore to give rise to the stable phase of high density. For capillary evaporation, we also find a multi-staged process, starting with the initial destabilization of the fluid structure followed by the formation of a bubble in the nanopore.