We have studied a relativistic electron in the presence of a uniform magnetic field and scalar potential in the cosmic string spacetime. The exact solutions of the Dirac equation with a Coulomb-like scalar potential and linear vector potential through the gravitational fields are found using SU (1, 1) Lie algebras.keyword: relativistic particle, Dirac equation, curved spacetime, SU(1,1)