There is uncertainty regarding what precisely causes the ruach ra’ah to linger on one’s hands. Is it the mere state of sleep, when a person’s consciousness abandons him and he is left without the ability to function, requiring even one who sleeps during the day to wash his hands three times upon awakening to remove the ruach ra’ah. Or, is it brought about by the night, when the entire world ceases its activities, and therefore even a person who was awake all night must wash his hands three times?
In practice, when both causes intertwine and someone sleeps at night a regular sleep (approximately half an hour), the ruach ra’ah rests upon him in full force. In such a case, immediately upon rising one must hurry to wash his hands three times and refrain from touching his bodily orifices or food prior to that washing. (Still, the berachah on this washing is only recited before Shacharit, as explained in halachah 5.)
It is proper for one who slept a regular sleep during the day to be stringent and wash his hands three times alternately, but it is unnecessary for him to rush to do so. Also, there is no prohibition forbidding him from touching his bodily orifices before he washes.[4]
Additionally, it is best that one who remained awake all night wash his hands three times at alot hashachar. Likewise, it is proper for a person who arose in the middle of the night and already washed his hands three times when he woke up to wash his hands alternately again when alot hashachar arrives, for perhaps the night itself and its cessation induce the ruach ra’ah.[5]
For the amount of sleep necessary to be considered a regular sleep, see Bei’ur Halachah 4:16 and Kaf HaChaim 4:55. Some say it is three hours and some say it is three minutes, though the average amount of time accepted by the majority of poskim is approximately half an hour, as I have written.
[5]. This is how the Shulchan Aruch 4:14 rules based on what he wrote in the Beit Yosef in the name of Orchot Chaim. According to this, presumably there is a need to be stringent not to touch one’s bodily orifices after alot hashachar until he washes his hands. (See also Hagahot of Rabbi Akiva Eiger 4:1, where it is implied that from the time he wakes up at night and washes his hands three times, he should not touch his bodily orifices until he washes his hands again three times after alot hashachar.) However, the opinion of the majority of poskim and kabbalists is that there is no lingering of the ruach ra’ah at the end of the night, and therefore, although we take into consideration the opinion of the Shulchan Aruch, and the minhag is that one who is up at night, or who wakes up before alot hashachar, goes back and washes his hands again three times after alot hashachar, nonetheless, we are not very strict about this. That is what the Eshel Avraham writes in 4:1, as well as Da’at Torah. Especially someone who is engrossed in Torah need not stop his learning in order to wash his hands. As it seems, regarding this law, we are even more lenient than we are about the ruling concerning one who sleeps during the day, as implied from Shulchan Aruch HaRav 4:13. In practice, after alot hashachar it is customary to wash again three times, but one need not be careful not to touch his bodily orifices, nor rush to wash at the moment alot hashachar arrives. In addition, there is doubt as to when exactly alot hashachar is (see further in this book 11:1). Therefore, after alot hashachar according to all opinions, he should wash his hands three times. One who is engrossed in Torah study should first finish the subject he is learning and then go wash his hands.