First, it is important to understand what a motion is. A motion is simply a request (usually in writing) to the judge to make a decision or take a particular action in the case. An opposition, then, is a response.
In terms of how to file one, that depends on how it is presented. If the motion is in writing, then the opposition typically is as well. Much like filing an answer to a petition, an opposition to a motion is filed with the clerk of court where the motion is filed. The clerk may charge a fee for filing it as well as for any copies that are requested.
The format of an opposition is usually the same as that of the motion itself, so it is useful to use the motion as a guide. However, some courts do have their own forms. (You can contact the clerk of court to see if one is available.) Otherwise, an opposition is captioned the same as the motion. And both the motion and the opposition detail why their perspective is the correct one.
Once filed, both are placed in the record and reviewed by the court prior to a hearing on the issue in dispute. At the hearing, the judge will listen to both sides - both the person who made the motion or request, and the person who opposes it, then make a decision.