More specifically, you place and hold one drum stick so that its tip rests roughly in the center of the drum head, and the shaft of the stick rests on the raised rim of the drum. Then you strike that stick with the other one, somewhere between the tip and where it's resting on the rim. This method is commonly used on a drum set or in the rare occasions when a rim shot is required for an orchestra or concert band.
The other method is an actual stroke and is executed with only one stick: you position the stick in the downstroke such that its tip strikes the head at the same time as the shaft strikes the rim. This is commonly used in marching bands and drum corps, in which the drum line is playing marching snares. A rim shot, or shot for short, is really damned loud on a marching snare. In drumspeak, it is "chauk". Another variant is the ping shot.