Hold the cabinet against the wall, above the toilet, where you plan to hang it. Place a level across the top of the cabinet to ensure it is sitting plumb. Have another person trace around the cabinet on the wall with a pencil, and then remove the cabinet.
Locate the studs in the tracing on the wall, using a stud finder. Drive a finishing nail around the stud locations to find the edges of the studs. Mark the edges of the studs on the wall with a straight vertical line, using a carpenter’s square.
Measure the locations of the studs relative to the tracing on the wall. Mark on the back of the cabinet the locations of the studs, using the same measurements.
Drill a guide hole through the back of the cabinet 2 inches below the top for each stud location. Also drill a pilot hole two inches above the bottom of the cabinet for each stud. Be sure that both pilot holes go through the wood rails on the back of the cabinet so there will be adequate support when you hang it.
Hold the cabinet against the wall again, lining it up with the tracing and confirming that it is level and plumb. Drive 3-inch-long wood screws through the guide holes in the back of the cabinet, sinking the screws into the wall studs.