Very accurate transition frequencies of HC$_5$N were determined between 5.3 and 21.4 GHz with a Fourier transform microwave spectrometer. The molecules were generated by passing a mixture of HC$_3$N and C$_2$H$_2$ highly diluted in neon through a discharge valve followed by supersonic expansion into the Fabry-Perot cavity of the spectrometer. The accuracies of the data permitted us to improve the experimental $^{14}$N nuclear quadrupole coupling parameter considerably and the first experimental determination of the $^{14}$N nuclear spin-rotation parameter. The transition frequencies are also well suited to determine in astronomical observations the local speed of rest velocities in molecular clouds with high fidelity. The same setup was used to study HC$_7$N, albeit with modest improvement of the experimental $^{14}$N nuclear quadrupole coupling parameter. Quantum chemical calculations were carried out to determine $^{14}$N nuclear quadrupole and spin-rotation coupling parameters of HC$_5$N, HC$_7$N, and related molecules. These calculations included evaluation of vibrational and relativistic corrections to the non-relativistic equilibrium quadrupole coupling parameters; their considerations improved the agreement between calculated and experimental values substantially.