(Abridged) We study the response of the gas to energetic processes associated with high-mass star formation and compare it with studies on low- and intermediate-mass young stellar objects (YSOs) using the same methods. The far-IR line emission and absorption of CO, H$_2$O, OH, and [OI] reveals the excitation and the relative contribution of different species to the gas cooling budget. Herschel-PACS spectra covering 55-190 um are analyzed for ten high-mass star forming regions of various luminosities and evolutionary stages at spatial scales of ~10^4 AU. Radiative transfer models are used to determine the contribution of the envelope to the far-IR CO emission. The close environments of high-mass YSOs show strong far-IR emission from molecules, atoms, and ions. Water is detected in all 10 objects even up to high excitation lines. CO lines from J=14-13 up to typically 29-28 show a single temperature component, Trot~300 K. Typical H$_2$O temperatures are Trot~250 K, while OH has Trot~80 K. Far-IR line cooling is dominated by CO (~75 %) and to a smaller extent by OI (~20 %), which increases for the most evolved sources. H$_2$O is less important as a coolant for high-mass sources because many lines are in absorption. Emission from the envelope is responsible for ~45-85 % of the total CO luminosity in high-mass sources compared with only ~10 % for low-mass YSOs. The highest-J lines originate most likely from shocks, based on the strong correlation of CO and H$_2$O with physical parameters of the sources from low- to high-masses. Excitation of warm CO is very similar for all mass regimes, whereas H$_2$O temperatures are ~100 K higher for high-mass sources than the low-mass YSOs. Molecular cooling is ~4 times more important than cooling by [OI]. The total far-IR line luminosity is about 10$^{-3}$ and 10$^{-5}$ times lower than the dust luminosity for the low- and high-mass YSOs.