Over the last two years, the Compact Muon Solenoid (CMS) detector has been installed in the tunnel of the Large Hadron Collider (LHC) at CERN and commissioned to its full functionality. The CMS detector successfully collected beam halo and beam dump data, while the beams were circulating in the LHC in September 2008. After the LHC incident, the commissioning of CMS continued with a one month campaign of continuous cosmic rays data taking at nominal magnetic field. This allowed further tuning of the detector, consolidation of its operation and characterization of its performances. In this talk, the status of the CMS detector and its performance, in view of LHC collisions in 2009, will be described.