An electrode through which current flows the other way (into the device) is termed an anode.
The word was coined in 1834 from the Greek κάθοδος (kathodos), 'descent' or 'way down', by William Whewell, who had been consulted by Michael Faraday over some new names needed to complete a paper on the recently discovered process of electrolysis. In that paper Faraday explained that when an electrolytic cell is oriented so that electric current traverses the "decomposing body" (electrolyte) in a direction "from East to West, or, which will strengthen this help to the memory, that in which the sun appears to move", the cathode is where the current leaves the electrolyte, on the West side: "kata downwards, `odos a way ; the way which the sun sets" (reprinted in ).
The use of 'West' to mean the 'out' direction (actually 'out' → 'West' → 'sunset' → 'down') may appear unnecessarily contrived. Previously, as related in the first reference cited above, Faraday had used the more straightforward term "exode" (the doorway where the current exits). His motivation for changing it to something meaning 'the West electrode' (other candidates had been "westode", "occiode" and "dysiode") was to make it immune to a possible later change in the direction convention for current, whose exact nature was not known at the time. The reference he used to this effect was the Earth's magnetic field direction, which at that time was believed to be invariant. He fundamentally defined his arbitrary orientation for the cell as being that in which the internal current would run parallel to and in the same direction as a hypothetical magnetizing current loop around the local line of latitude which would induce a magnetic dipole field oriented like the Earth's. This made the internal current East to West as previously mentioned, but in the event of a later convention change it would have become West to East, so that the West electrode would not have been the 'way out' any more. Therefore "exode" would have become inappropriate, whereas "cathode" meaning 'West electrode' would have remained correct with respect to the unchanged direction of the actual phenomenon underlying the current, then unknown but, he thought, unambiguously defined by the magnetic reference. In retrospect the name change was unfortunate, not only because the Greek roots alone do not reveal the cathode's function any more, but more importantly because, as we now know, the Earth's magnetic field direction on which the "cathode" term is based is subject to reversals whereas the current direction convention on which the "exode" term was based has no reason to change in the future.
Since the later discovery of the electron, an easier to remember, and more durably technically correct (although historically false), etymology has been suggested: cathode, from the Greek kathodos, 'way down', 'the way (down) into the cell (or other device) for electrons'.
The flow of electrons is always from anode to cathode outside of the cell or device, regardless of the cell or device type and operating mode, with the exception of diodes where electrode naming always assumes current flows in the forward direction (that of the arrow symbol), i.e., electrons flow in the opposite direction, even when the diode reverse-conducts either by accident (breakdown of a normal diode) or by design (breakdown of a Zener diode, photo-current of a photodiode or solar cell).
In a semiconductor diode, the cathode is the N–doped layer of the PN junction. Initially, the N-doped layer supplies electrons to flow into the junction (N-doped for negative charge carriers). The electrons given by the N-doped layer combine with 'holes' supplied from the P-doped layer. The electrons and holes combining create a 'depleted' zone at the junction, leaving behind in the cathode a thin layer of positive ions which gives a base positive charge to the junction's cathode side of the device. (The anode side has a base negative charge at the junction, since it supplied 'holes' to the recombinant region and the doped ions have one electron more than their full valence shell of electrons). As a negative charge is applied to the cathode from the circuit external to the diode, more N-doped ions are able to supply electrons to the recombinant region and the diode becomes conductive, which allows electrons to flow though the diode from the cathode to the anode (electrons flow from the N-doped to the P-doped side when the bias is overcome). Like a typical diode, there is a fixed anode and cathode in a zener diode, but it will conduct current in the reverse direction (electrons from anode to cathode) if its breakdown or Zener voltage is exceeded.