An analytical formalism for the solution of cumulative beam breakup in linear accelerators with arbitrary time dependence of beam current is presented, and a closed-form expression for the time and position dependence of the transverse displacement is obtained. It is applied to the behavior of a single bunch and to the steady-state and transient behavior of dc beams and beams composed of pointlike and finite-length bunches. This formalism is also applied to the problem of cumulative beam breakup in the presence of random displacement of cavities and focusing elements, and a general solution is presented.