Bicycles are considered vehicles and have as much right to the streets as cars, trucks and motorcycles. The only exception are limited access highways such interstates, which often prohibit bicycles. If you ride too far to the right, you will get a lot of flats from running over glass and other debris, you could crash from hitting sewer grates, and many cars will try to squeeze by without giving you any space. It is better to "own" some of the road, but don't get carried away with it. There is no point tying up traffic for miles riding down the center of a road when there is plenty of space for a bike and a car. Paved shoulders are fine as long as they are not clogged with debris.
You can increase your comfort level by using a mirror, wearing high-viz jerseys or jackets, and installing a bright tail-light on your bike, helmet or seatbag. In my experience, drivers pulling or backing out from side streets and parking lots are a bigger hazard than getting hit from behind. Another more likely hazard is hitting potholes, large sticks, rocks, glass and other debris -- or drivers flinging open their car doors when parked along the street -- so keep your eyes on the road ahead of you.