We propose to generate few-fs or as X-ray laser pulses by beating of two or more X-ray laser lines with appropriate frequency separation. X-ray lasers operating on transitions in neon- or nickel-like ions typically have gain on several lines with difference frequencies of around 1015 Hz. Moreover, it is found in specific cases that a few almost equidistant lines may exhibit gain. Beating of these lines results in a series of pulses with durations down to the attosecond range. It is shown that phase locking can be achieved by means of a Langmuir wave in the X-ray laser medium itself, which is resonant with the difference frequency.