If you live in an earthquake-prone area, or have children or pets, securing your bookcases to the wall should be a high safety priority. Even if your living space meets none of these criteria, it's not a bad idea -- a fully-loaded 1.8 m (6 foot) tall bookcase could easily weigh 318 kg (700 lb). If your bookcases have glass doors, it is even more likely that they would fall forward under stress. Securing the bookcases to the floor, or putting the heavy books on the bottom shelves, will not keep the bookcases from tipping forward and falling over.
Unload the bookcase and move it out from the wall. Use a stud finder to locate the wall studs behind the bookcase. Draw vertical lines up the wall to indicate where the studs are. Use a plumb line. The line should end about 15 cm (6 inches) down from where the top of the bookcase will be.
Measure the width of a bookcase shelf; do not include the sides of the bookcase.
Cut a 2.5 x 15 cm (1 x 6 inch) piece of timber to match the length of the shelves of the bookcase. You may want to paint this piece of wood to match your walls, but if your bookcase is full of books, it won't show in any case.
Move the bookcase back into place. Place the board you cut against the wall under the top shelf of the bookcase. Transfer the lines that show where the studs are located to the board.
Put the board on your work surface and drill a 1.5 mm (1/16 inch) pilot hole through the board at the line or lines that show where the studs are. Use an electric drill. Put the board back in place and affix it to the wall using 7.5 cm (3 inch) long wood screws. The screws must go through the board and the plasterboard, then into the stud.
Attach the top shelf of the bookcase to the board using 5 cm (2 inch) L-brackets. Use 1.2 cm (1/2 inch)long screws to attach two L-brackets to the underside of the top shelf. You may want to make this job easier by removing the bookcase from the wall and laying it down on the floor so the back of the bookcase is facing upward. Screw the other arms of the L-brackets into the wooden board. Put the books back.