  The elastic properties of the $B_1$-structured transition-metal nitrides and
their carbide counterparts are studied using the {\it ab initio\} density
functional perturbation theory. The linear response results of elastic
constants are in excellent agreement with those obtained from numerical
derivative methods, and are also consistent with measured data. We find the
following trends: (1) Bulk moduli $B$ and tetragonal shear moduli
$G^{\prime}=(C_{11}-C_{12})/2$, increase and lattice constants $a_{0}$ decrease
rightward or downward on the Periodic Table for the metal component or if C is
replaced by N; (2) The inequality $B > G^{\prime} > G > 0$ holds for
$G=C_{44}$; (3) $G$ depends strongly on the number of valence electrons per
unit cell ($Z_{V}$). From the fitted curve of $G$ as a function of $Z_{V}$, we
can predict that MoN is unstable in $B_{1}$ structure, and transition-metal
carbonitrides ($e.g.$ ZrC$_{x}$N$_{1-x}$) and di-transition-metal carbides
($e.g.$ Hf$_{x}$Ta$_{1-x}$C) have maximum $G$ at $Z_{V} \approx 8.3$.
