The next-generation wireless technologies, commonly referred to as the sixth generation (6G), are envisioned to support extreme communications capacity and in particular disruption in the network sensing capabilities. The terahertz (THz) band is one potential enabler for those due to the enormous unused frequency bands and the high spatial resolution enabled by both short wavelengths and bandwidths. Different from earlier surveys, this paper presents a comprehensive treatment and technology survey on THz communications and sensing in terms of the advantages, applications, propagation characterization, channel modeling, measurement campaigns, antennas, transceiver devices, beamforming, networking, the integration of communications and sensing, and experimental testbeds. Starting from the motivation and use cases, we survey the development and historical perspective of THz communications and sensing with the anticipated 6G requirements. We explore the radio propagation, channel modeling, and measurements for THz band. The transceiver requirements, architectures, technological challenges, and approaches together with means to compensate for the high propagation losses by appropriate antenna and beamforming solutions. We survey also several system technologies required by or beneficial for THz systems. The synergistic design of sensing and communications is explored with depth. Practical trials, demonstrations, and experiments are also summarized. The paper gives a holistic view of the current state of the art and highlights the issues and challenges that are open for further research towards 6G.