The great scholar of hadeeth, An-Nawawee, mentioned these hadeeths in his book, Riyaadus Saaliheen, regarding etiquettes of greetings. One of them is the hadeeth of Al-Miqdad bin Al-Aswad - may Allah be pleased with him - that the Prophet ﷺ used to enter the house at night and offer low greeting in such manner audible only to those who are awake without disturbing those asleep.
This is the proper etiquette when one enters a house, room or similar space wherein there are people who are asleep and others who are awake. He should offer greeting which will be heard by those who are awake without awakening those who are asleep. This is because the one who is asleep will not like to be disturbed by anyone. Indeed, there are people who find it hard to sleep once stirred and would remain awake until dawn. This will cause harm and inconvenience to these people. So, when you enter a place in which there are people who are awake and others who are asleep, you should give those who are asleep their right by offering a low-pitched greeting which will be audible to those who are awake without arousing those who are asleep.
Then the author mentioned the hadeeth of Asma - may Allah be pleased with her - about the passage of the Prophet ﷺ by some women in the mosque. He ﷺ gestured to them with his hands by way of greeting. The author - may Allah shower blessings on him - then said: ‘This should be understood to mean that he ﷺ combined greeting with the hands and greeting with the tongue.’ This is because greeting by gesture of the hand alone is prohibited; the Prophet ﷺ prohibited it. However, it is alright to combine the two especially if the person is far away, deaf or for other similar reasons. This may require that he sees the motion of the hand of the one making Salam.
In this case, one should combine the greeting (with the tongue) and the gesturing (with the hand).
As for what some people do nowadays of sounding the car horn when driving by, this is neither a Salam nor part of the Sunnah. However, some people may say: 'I do not intend Salam by it; rather, I wish to call the person's attention then make Salam to him.' Well, I hope that there is no problem with this. But there is no doubt that making it a substitute for Salam is contrary to the Sunnah. The Sunnah is to greet with the tongue. If the voice cannot be heard, then he should gesture with the hand till the one far off or the deaf takes cognizance of his greeting.
In the hadeeth of Asma bint Yazid - may Allah be pleased with her, the Prophet ﷺ passed through the mosque and a group of women were seated in it, he gestured to them to offer greeting. An-Nawawee said: 'This should be understood that he combined Salam with gesturing.' This is because greeting with gestures alone is prohibited. The Salam must necessarily be by saying: 'As-Salam alayka,' if it is directed to a person and 'As-Salam Alaykum,' if it is directed to a group of people. However, if a person is far away, deaf or surrounded by noise, gesture should be combined with the statement: 'As-Salam alaykum.'
In this hadeeth, the Prophet ﷺ greeted a group of women. This is because the dreaded evil is totally non-existent; otherwise, a strange man, one who is not an unmarriageable relative of a woman, should not greet her due to the attendant danger. This is more serious for a young male and a young female; a young man should not greet a young woman and vice versa.
Nevertheless, if a man known for good character passes by a group of women in a mosque, class or similar spaces, there is no harm if he greets them. This is because the dreaded evil is non-existent since there is regular inflow and outflow of people in the mosque. However, there is great danger in greeting a young girl on the street or in the market; hence, you should not greet her.
Similarly, if he enters his house and meets a group of women visiting his wife, there is no harm in greeting them because the dreaded evil is
absent. As for the reason for this profound caution, we have the legal maxim which states that: Prevention of evil supersedes attainment of benefit, Darr' Al-Mafasid awla min jalb Al-Masalih.
From the foregoing, we know that handshaking women is not permissible, be it an old woman or a young woman, with gloves or without it, because of the associated danger. However, it is permissible for an unmarriageable male relative to shake a female relative, and Allah knows best.
As for saying: 'Alayka As-Salam – upon you be peace.' The Prophet ﷺ prohibited this and said: 'This is the greeting of the dead.' That is, during the Pre-Islamic era, they used to greet the dead in that manner. This can be deduced from the statement of a poet:
Upon you be the peace of Allah, O Qays bin Amir
Whenever they address the dead, even if they are far away from his grave, they would do so in present tense with: 'Alayka As-Salam – Upon you be peace of Allah.' Hence, the Prophet ﷺ prohibited it because it is the greeting for the dead and an imitation of the people of Jahiliyyah in their ignorance. Rather than saying: 'Alayka As-Salam,' you should say: 'As-Salam alayka.' This is the correct Islamic greeting, and Allah knows best.