Cyber–physical systems (CPSs) are new types of intelligent systems that integrate computing, control, and communication technologies, bridging the cyberspace and physical world. These systems enhance the capabilities of our critical infrastructure and are widely used in a variety of safety-critical systems. CPSs are susceptible to cyber attacks due to their vulnerabilities such that their security has become a critical issue. Therefore, it is important to classify and comprehensively investigate this issue. Most of the existing surveys on it are conducted from a single perspective. In this article, we present a comprehensive view of the security of CPSs from three perspectives: 1) the physical domain; 2) the cyber domain; and 3) the cyber–physical domain. In the physical domain, we review some attacks that directly damage the physical components of CPSs such as sensors and discuss corresponding defenses. We also review the attacks that CPSs in the cyber domain may face and study methods to detect and defend against them. In addition, we survey the intelligent attacks faced by CPSs and the corresponding defensive means. In the cyber–physical domain, we provide an overview of attacks that come from the cyber domain and eventually damage the physical parts, and discuss the corresponding detection and defense methods. Finally, we present the challenges and future research directions. Through this in-depth review, we attempt to summarize the current security threats to CPSs and the state-of-the-art security means to provide researchers with a comprehensive overview.