Place a stud finder on the wall and slide it horizontally to locate the studs.
Hold an L-bracket onto the shelf so that the bend faces you with the top of the bracket on the wall and the bottom lying flat on the bookshelf.
Screw the bracket into the wall where the wall stud is located using 3-inch screws.
Screw the other side of the bracket into the bookshelf using 1/2-inch screws or screws that are appropriate to the thickness of the shelf.
Install the brackets near the top on each side of the shelf on two separate studs.