A new state estimation method is proposed in this manuscript for a class of linear cyber-physical systems (CPSs) with sparse sensor attacks, unknown input and output disturbances. The sensor attack will make part of the measurement signal received by the remote observer inaccurate. In order to achieve the secure state estimation (SSE) for the investigated linear CPSs, an unknown input observer (UIO) with adaptive switching mechanism is designed. Inspired by the existing results, a set of sub-observers is designed which can exclude the influence of unknown input and output disturbances. To achieve switching between different sub-observers, the adaptive switching mechanism is designed according to the switching adversarial principle. Some parameters of the observer are obtained by designing a set of linear matrix inequalities (LMIs). The sufficient condition for the existence of the observer and the proof of its effectiveness are respectively given by theoretical analysis. Finally, the effectiveness of the proposed method is proved by two Matlab simulation experiments.