We used optical tweezers to rotate bacterial cells relative to the optical axis. We rapidly oscillate the optical tweezers along an axis normal to the laser beam, thereby obtaining a linear trap. When the linear trap is longer than a trapped rod-shaped bacterial cell, the cell is aligned along the trap axis. Decreasing the length of the trap, we found that the cell rotates away from the image plane toward the optical axis. In the limit of a nonoscillating trap, the cell aligns along the optical axis. A defocused-edge detection method was devised to measure the orientation of the rotated cell from the corresponding phase-contrast images. Our technique can be used to image three-dimensional sub-cellular structures from different viewpoints and therefore may become a useful tool in fluorescence microscopy.