The nitrile function can easily be introduced by reaction of cyanide, either by substitution or addition.
Nucleophilic Substitution
Diazonium Salts Displacement
Cyanide Addition to Aldehydes and Ketones
The perhaps simplest carbon nucleophile, cyanide, adds to aldehydes and ketones to render cyanohydrins.
Conjugated Addition to alpha,beta-Unsaturated Compounds
Aldoximes are obtained by reaction of hydroxylamine with aldehydes.
Their dehydration with a water avid compound like an anhydride, leads to a nitrile.
Primary amides can be dehydrated with strong dehydrating agents like phosphorous pentoxide yielding nitriles.