It is a reaction between a nucleophile (gives electrons away) and an electrophile (attract electrons). A leaving group on the electrophile is needed for this reaction to happen.
There are two types of nucleophilic substitution reactions: SN1 and SN2.
In SN1 the 1 means that there is one species reacting in the lowest step and this reaction is a step by step process; in SN2, the 2 means that there are two species reacting in the lowest step and this reaction happens at the same step.
In SN1, first a carbocation will form and then the nucleophile will attack it. The nucleophile can attack from both sides (backside and front side) as this happens in two steps. In