If you have a door that opens or shuts on its own, it could be a poltergeist, but more likely the house has settled and the door frame is no longer square.
The correct way to fix the problem is to remove the door and all of its trim and then plumb up the frame. There are a few easier options that might alleviate the problem.
Step 1: For a door that won’t stay open, consider installing a door stop that locks the door in place. Screw the smaller piece of the stop to the door and the larger portion to the baseboard behind the door. Apply a little pressure when opening the door and the problem should be solved.
Step 2: Use a screwdriver to tighten all of the door hinge screws. If the door was sagging because of a loose hinge, this simple step will fix the problem.
Step 3: If the door still swings open or closed after tightening the screws, shut the door and carefully examine it. Chances are there will be a larger gap either at the top or bottom of the hinged side of the door. Shimming the frame side of a hinge to lessen the gap may solve the problem.
Step 4: Place a door wedge, book or piece of rolled up cardboard beneath the open door to support the door while you address the hinges.
Step 5: Remove the jamb-side hinge screws on the top or bottom hinge, depending on where the larger gap is.
Step 6: Place a prefabricated door hinge shim, or a piece of chip board cut to match the hinge size, into the mortise of the door jamb. Reattach the hinge on top of the shim. Make sure to hand-tighten the screws completely.
Step 7: An option for shimming the hinge is to remove the door-side hinge screws on the hinge with the smaller gap. Use a wood chisel and sand paper to slightly deepen the mortise under the hinge. Be careful not to remove too much wood; once wood is removed, it can’t be replaced.
Step 8: Test the door to see if it opens and closes properly. Make adjustments if necessary.
If the door still swings open or shut, removing the door and trim to plumb the frame may be the only solution … but that’s a job for another week.