The rules for determining a unit's line of sight are given on here, but in the case of shooting, each model firing needs to see its target (instead of using the entire unit's line of sight). It sometimes happens that some models in a firing unit will have line of sight to the target while other models in the unit will not (the target may be out of their arc of sight or obscured by terrain or other models). If this is the case, only those that have line of sight to the target can shoot and the rest automatically miss.
Remember that models and terrain block line of sight. This means that only models in the front rank of a unit are normally able to shoot, as those behind will not be able to see past their friends.