The Compact Muon Solenoid (CMS) experiment is one of the two general-purpose detectors built at the Large Hadron Collider. Although mainly designed as a particle physics detector, the CMS experiment has demonstrated excellent and unique capabilities in studying properties of the quark gluon plasma during the LHC heavy ion program, owing to its comprehensive abilities in detecting a variety of particle species over wide coverages. In this talk, I will introduce the present CMS experiment including its various subsystems, with an emphasis on the particle identification (PID) capabilities. I will highlight results where PID information played a crucial role from ion runs. With the planned high-luminosity LHC upgrade in 2029, the CMS experiment will undergo a series of major upgrades in the following years. I will discuss a new high-precision, hermetic time-of-flight detector upgrade that will provide new PID capability of charged hadrons at CMS for the LHC Run 4 and beyond.