A cart-pendulum system is a typical underactuated mechanical system with two degrees of freedom and one control input. The fixed-time stabilization control problem for this system is studied in this paper. A fixed-time hierarchical sliding mode control method is developed to solve this problem. Firstly, the system is divided into two subsystems. And two first-level sliding mode surfaces are designed for these two subsystems respectively. Secondly, a second-level sliding mode surface is constructed by linearly combining two first-level sliding mode surfaces. After that, a hierarchical sliding mode controller is designed based on the designed sliding mode surfaces. It enables the state variables of closed-loop control system to be stabilized at the origin within a fixed-time. This means that the settling time can be limited within a range and does not depend on the initial state value of the system. Finally, a numerical example is given to show the effectiveness of the developed control method.