Measurements are presented of the lifetimes of the B0 , Bs0 , Λb0 , and Bc+ hadrons using the decay channels B0→J/ψK∗(892)0 , B0→J/ψKS0 , Bs0→J/ψπ+π- , Bs0→J/ψϕ(1020) , Λb0→J/ψΛ0 , and Bc+→J/ψπ+ . The data sample, corresponding to an integrated luminosity of 19.7 fb-1 , was collected by the CMS detector at the LHC in proton-proton collisions at s=8TeV . The B0 lifetime is measured to be 453.0±1.6(stat)±1.8(syst)μm in J/ψK∗(892)0 and 457.8±2.7(stat)±2.8(syst)μm in J/ψKS0 , which results in a combined measurement of cτB0=454.1±1.4(stat)±1.7(syst)μm . The effective lifetime of the Bs0 meson is measured in two decay modes, with contributions from different amounts of the heavy and light eigenstates. This results in two different measured lifetimes: cτBs0→J/ψπ+π-=502.7±10.2(stat)±3.4(syst)μm and cτBs0→J/ψϕ(1020)=443.9±2.0(stat)±1.5(syst)μm . The Λb0 lifetime is found to be 442.9±8.2(stat)±2.8(syst)μm . The precision from each of these channels is as good as or better than previous measurements. The Bc+ lifetime, measured with respect to the B+ to reduce the systematic uncertainty, is 162.3±7.8(stat)±4.2(syst)±0.1(τB+)μm . All results are in agreement with current world-average values.