Simply put, any atom attached to a stereocenter or alkene bond carbon (or similar double bond system) has a Cahn-Ingold-Prelog priority corresponding to its atomic numberthe higher the atomic number, the higher the priority.
If two atoms attached to the stereocenter have the same atomic number, then the sum of the atomic numbers of the atoms one bond further from the stereocenter are totalled, and so on progressing out from the stereocenter until one branch or the other originating at the stereocenter is found to have higher priority. (If no such difference is found, then the center in question does not have different configurations that need to be distinguished using this nomenclature). If a multiple bond is encountered during this process, it is counted twice or three times as appropriate.
After the substituents of a stereocenter have been assigned their priorities, the molecule is so oriented in space that the group with the lowest priority is pointed away from the observer. If the lowest priority substituent is assigned the number 1, and the highest 4, then the sense of rotation of a route passing through 2, 3 and 4 distinguishes the stereoisomers. A center with a clockwise sense of rotation is an R or Rectus center and a center with an anticlockwise sense of rotation is an S or Sinister center. The names are derived from the Latin for right and left.
For alkenes and similar double bonded molecules, the same prioritising process is followed for the substituents. In this case, it is the placing of the two highest priority substituents with respect to the double bond which matters. If both high priority substituents are on the same side of the double bond, ie in the cis configuration, then the stereoisomer is assigned a Z or Zusammen configuration. If, by contrast they are in a trans configuration, then the stereoisomer is assigned an E or Entgegen configuration. In this case the identifying letters are derived from German.
It is important to note that there can be more than one of each type of system requiring assignment in a particular molecule. For example, ephedrine exists in both 1-(R), 2-(S) and 1-(S), 2-(R) forms. A compound with the same formula also exists in 1-(R), 2-(R) and 1-(S), 2-(S). Said stereoisomers are not ephedrine, but pseudoephedrine. They are chemically distinct from ephedrine, with only the three dimensional configuration in space, as notated by the Cahn-Ingold-Prelog rules to distinguish them in systematic nomenclature (both are 2-methylamino-1-phenyl-1-propanol in systematic nomenclature). The ephedrine enantiomers are referred to as being diastereoisomers of the pseudoephedrine enantiomers. In general where there are n stereocenters, there will be 2n stereoisomers possible. However, often there are situations where some of these stereoisomers are superimposable, reducing the number of different molecules which actually exist.
It should also be noted that a common misnomer is to label tetrahedral atoms with four distinct substituents as chiral centers. This is incorrect, since merely because a center has such a structure does not mean that it is part of a chiral molecule. It may be part of a molecule which is an optically inactive diastereoisomer. They should correctly be labelled as stereocenters.