Using the exact Bethe ansatz solution of the Hubbard model and Luttinger liquid theory, we investigate the density profiles and collective modes of one-dimensional ultracold fermions confined in an optical lattice with a harmonic trapping potential. We determine a generic phase diagram in terms of a characteristic filling factor and a dimensionless coupling constant. The collective oscillations of the atomic mass density, a technique that is commonly used in experiments, provide a signature of the quantum phase transition from the metallic phase to the Mott-insulator phase. A detailed experimental implementation is proposed.