We aim to reveal the gas energetics in the circumstellar environment of the prototypical high-mass protostellar object AFGL2591 using space-based far-infrared observations of linear rotor molecules. Rotational spectral line signatures of CO, HCO+, CS, HCN and HNC from a 490-1240 GHz survey with Herschel/HIFI, complemented by ground-based JCMT and IRAM 30m spectra, cover transitions with E(up)/k between 5 and ~300 K (750K for 12C16O, using selected frequency settings up to 1850 GHz). The resolved spectral line profiles are used to separate and study various kinematic components. The line profiles show two emission components, the widest and bluest of which is attributed to an approaching outflow and the other to the envelope. We find evidence for progressively more redshifted and wider line profiles from the envelope gas with increasing energy level, qualitatively explained by residual outflow contribution picked up in the systematically decreasing beam size. Integrated line intensities for each species decrease as E(up)/k increases from <50 to 700K. We constrain the following: n(H2)~10^5-10^6 cm^-3 and T~60-200K for the outflow gas; T=9-17K and N(H2)~3x10^21 cm^-2 for a known foreground absorption cloud; N(H2)<10^19 cm^-2 for a second foreground component. Our spherical envelope radiative transfer model systematically underproduces observed line emission at E(up)/k > 150 K for all species. This indicates that warm gas should be added to the model and that the models geometry should provide low optical depth pathways for line emission from this warm gas to escape, for example in the form of UV heated outflow cavity walls viewed at a favorable inclination angle. Physical and chemical conditions derived for the outflow gas are similar to those in the protostellar envelope, possibly indicating that the modest velocity (<10 km/s) outflow component consists of recently swept-up gas.