The target metal in an X-ray tube is some heavy metal, such as tungsten, which has an atomic number of 74 with a shell structure of K2.L8.M18.N32.O12.P2. What this means is that at ground state, the K-shell (the innermost shell) is filled by 2 electrons, the L-shell (the next higher shell) is filled by 8 electrons, and so on.
The binding energies for a K, L and M shell electron are 69.5 keV, 10.2 keV and 1.8 keV respectively. Binding energy is the amount of energy required to dislodge an electron from the atom[1].
Under normal circumstances, the inner shell electrons live an uneventful life. They can’t be excited or de-excited into neighbouring shells, since those shells have been completely filled. It is also impossible for them to leave the atom. The K-shell electrons in particular require 69.5 keV, a humongous amount of energy for an electron, to be liberated from the atom. But the filament electrons really pack a punch.
Let’s assume that our x-ray tube has an accelerating voltage of 100 kV. This means the filament electrons (which left the anode with negligible KE) would have gained 100 keV of KE (at the expense of losing 100 keV of EPE) by the time they come knocking on the K shell electrons. At 100 keV, the filament electron has sufficient KE to knock out a K-shell electron, leaving behind a vacancy in the K-shell. The race to fill this vacancy is on!
Usually, it is an L-shell electron that wins the race. In making the transition from L shell (binding energy 10.2 keV) to K shell (binding energy 69.5 keV), the atom must lose of energy. This energy is released as a 59.3 keV x-ray photon. This is called a Ka photon.
But this is not the end of the story because a vacancy has just opened up in the L shell. If this vacancy is filled by a M-shell electron, the transition from M to L shell will produce a photon with energy . This is called a La photon.
Occasionally, an M-shell (binding energy 1.8 keV) beats an L-shell electron to fill the K-shell vacancy. In that case, the M to K-shell transition would produce an even more energetic x-ray photon with energy of . This is called a Kb photon.
In short, whenever a K-shell electron is knocked out of the atom, a “domino chain reaction” is triggered in which electrons from successive higher shells “cascade” down to fill up the successive vacancies that open up. Since these down transitions produce characteristic x-ray photons with energies corresponding to the energy gaps between the transitioning shells, this cascading action produces a line spectrum.
Furthermore, since each metal has its own unique energy structure, each metal will produce its own signature line spectrum. This is why they are called characteristic lines.
The characteristic x-ray spectrum is kind of similar to the discrete line spectrum of hot gases, as both are produced by atoms making down transitions. The main difference is the magnitude of energies involved. Take for example hydrogen which has a paltry ionization energy of 13.6 eV. There is no way we can milk x-ray photons out of hydrogen atoms. X-ray is a game played by big boys such as tungsten atoms whose ionization energy is of the order of keV. Another difference is that to initiate the cascading down transitions, a K-shell electron must first be completely dislodged from the atom, since the inner shells are usually completely filled up. This is unlike the emission spectrum, where electrons only need to be excited from the ground level to some higher (vacant) energy levels, without any electron having to leave the atom completely.
[1] So binding energy is actually an energy deficit rather than energy available.