You can only select an enemy unit as a target if your unit can see it, or at least part of it. Obviously, a unit cannot open fire if there is a hill, building, or some other large object in the way.
Sometimes it may be hard to tell if a line of sight is blocked or not, so players must stoop over the table for a 'model's eye view'. This is the best way to see if a line of sight exists.
Models in the attacking unit do not block a line of sight (they duck, crouch or get out of the way). Likewise ignore units from your own side (your unit conducts its firing at a convenient moment when their compatriots are not in the way). Enemy models and all vehicles, friend or foe, do block a unit's line of sight if they are in the way, just like buildings and other terrain. Enemy models will block the line of sight to other models up to twice their height.
Diagram: Line of Sight. A group of Space Marines is positioned behind a patch of jungle terrain, out of line of sight of a Dark Eldar unit and a Land Speeder on the other side. The caption notes the Dark Eldar can see and shoot at the Land Speeder, but not at the Space Marine squad, because the jungle blocks their view of the squad.
Individual models in the unit that don't have a line of sight to the target unit cannot fire, and any models in the target unit that cannot be seen by their attackers cannot be hit by their firing.
Diagram: Partial Line of Sight. A Whirlwind vehicle and several Space Marines are shown on open ground beside a rocky outcrop, with a unit of Dark Eldar nearby. Models in the shaded area behind the rocks have no line of sight to the Dark Eldar and cannot shoot, but all the models outside the shaded area can see at least one of the Dark Eldar and so can shoot at them.