Use a compass to scribe your line onto your rail.
A scribe rail is a wooden rail which has the imperfections of a wall surface transferred to it and cut away. The result is a rail that sits flush against the wall surface with very few, if any, gaps between the rail and the wall. This scribe rail helps your kitchen cabinets sit flush against the rail rather than having gaps between the cabinets and the wall. Scribe rails are hidden behind the cabinets so there's no need to stain or paint them.
Video of the Day
Find your studs. Use a stud finder to locate the studs and draw a line down the wall to mark the location of the studs.
Hold a 2-by-4 piece of wood the same length as the run of kitchen cabinets to your wall. Position the wood so it's running horizontally and will be hidden by the cabinets. Hold the widest section flat against the wall.
Insert a pencil into your compass and position the compass so the needle is against the wall and the pencil is on the wood. Pull the compass down the wall, scribing the wall's imperfection onto the wood.
Cut down your scribed line with a saw.
Return your scribe rail to the wall and screw it in place. Screw through the scribe rail and into the studs.
Predrill your screw holes in your scribe rail to help prevent splintering the rail.
For tall cabinets, you may need more than one scribe rail.
Always wear eye protection when sawing or drilling.