Loosen all of the screws that secured the old cabinets to the wall. Set the screws, washers and any other relevant hardware aside to use for later. Remove and save any hardware on the cabinets that might be useful for future projects, including saving the entire cabinets if they are not damaged, as they make excellent desk supports.
Position long nails in the wall holes so that their sharp ends are sticking out about 1/4-inch and their blunt ends push up against the back of the hole. Do not hammer them in, but just set them in the holes. Hold a new cabinet near the wall in the intended position but not touching it, using the help of an assistant or two. Assistants are especially helpful if holding the cabinet up off the floor. Put a carpenter's level on top of the cabinet and make sure it is straight and adjust its tilt based on the level's reading.
Force the new cabinet back against the wall with the help of the assistants, keeping it straight the entire time, to make small indentations at each screw hole location. Remove the new cabinet from the wall and set it on the working surface with its rear board facing upward.
Drill a hole at the location of each indentation all the way through the back of the cabinet using a wood drill bit slightly smaller in diameter than the wood screws. Remove the nails from the wall holes and set the cabinet against the wall. Slide the old installation screws or new 3-inch wood screws through washers and into the cabinet holes and through into the wall holes.
Set the level on the cabinet again to make sure it is straight, and make any adjustments necessary. Use a drill to screw each wood screw halfway into the wall, and then tighten them all fully once they are all partway installed.
Repeat to add additional cabinetry, adding new holes if necessary but making sure that they are positioned over wall studs by first finding the studs with a stud finder.