Context : Aims : Our aim is to study the response of the gas to energetic processes associated with high-mass star formation and compare it with previously published studies on low- and intermediate-mass young stellar objects ( YSOs ) using the same methods . The quantified far-infrared line emission and absorption of CO , H _ { 2 } O , OH , and [ O i ] reveals the excitation and the relative contribution of different atomic and molecular species to the gas cooling budget . Methods : Herschel-PACS spectra covering 55–190 \mu m are analyzed for ten high-mass star forming regions of luminosities L _ { \mathrm { bol } } \sim 10 ^ { 4 } -10 ^ { 6 } L _ { \odot } and various evolutionary stages at spatial scales of \sim 10 ^ { 4 } AU . Radiative transfer models are used to determine the contribution of the quiescent envelope to the far-IR CO emission . Results : The close environments of high-mass protostars show strong far-infrared emission from molecules , atoms , and ions . Water is detected in all 10 objects even up to high excitation lines , often in absorption at the shorter wavelengths and in emission at the longer wavelengths . CO transitions from J = 14 - 13 up to typically 29 - 28 ( E _ { \mathrm { u } } / k _ { \mathrm { B } } \sim 580 - 2400 K ) show a single temperature component with a rotational temperature of T _ { \mathrm { rot } } \sim 300 K. Typical H _ { 2 } O excitation temperatures are T _ { \mathrm { rot } } \sim 250 K , while OH has T _ { \mathrm { rot } } \sim 80 K. Far-IR line cooling is dominated by CO ( \sim 75 % ) and to a smaller extent by [ O i ] ( \sim 20 % ) , which becomes more important for the most evolved sources . H _ { 2 } O is less important as a coolant for high-mass sources due to the fact that many lines are in absorption . Conclusions : Emission from the quiescent envelope is responsible for \sim 45 - 85 % of the total CO luminosity in high-mass sources compared with only \sim 10 % for low-mass YSOs . The highest - J lines ( J _ { \mathrm { up } } \geq 20 ) originate most likely from shocks , based on the strong correlation of CO and H _ { 2 } O with physical parameters ( L _ { \mathrm { bol } } , M _ { \mathrm { env } } ) of the sources from low- to high-mass YSOs . Excitation of warm CO described by T _ { \mathrm { rot } } \sim 300 K is very similar for all mass regimes , whereas H _ { 2 } O temperatures are \sim 100 K higher for high-mass sources compared with low-mass YSOs . The total far-IR cooling in lines correlates strongly with bolometric luminosity , consistent with previous studies restricted to low-mass YSOs . Molecular cooling ( CO , H _ { 2 } O , and OH ) is \sim 4 times more important than cooling by oxygen atoms for all mass regimes . 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 star forming regions , respectively .