The Ettiquette & Rules of Greeting
Quran 4 :86 And when you are greeted with a greeting, greet with a better (greeting) than it or return it; surely Allah takes account of all things.
The Prophet (saws) said - Greeting with Peace ( salam) is a voluntary act whereas returning it is an obligation -kanzul amal no25294
The Prophet (saws) said :-
The young should greet the old
A single individual should greet two together
The fewer number should greet the larger number
The person on horseback should greet the person on foot
The person walking should greet the one standing
The person standing should greet the one standing
Source Mizan ul Hikmah kanzul amal no25321
The Prophet saws said -There are 5 things I will never leave until death...and greeting the young in order that it may remain a practice after me -bihar v76 p10 no 38
Imam Baqir (as) said- Do not extend greeting of peace... and to those who drink alcohol ,nor to chess & dice players,nor to an effimante person ,nor to someone performing his prayer ( because he cannot return the greeting)bihar v76 p9no 35
http://islamic-laws.com/tawzeh/119.html
1146. A
person offering prayers should not greet anyone with Salam, and if another
person says Salam to him, he should use the same words in reply without adding
anything to it.
For example, if someone says Salamun alaykum, he should also say Salamun 'alaykum
in reply, without adding Wa rahmatullahi wa barakatuh. As an obligatory
precaution, he should not utter 'Alaykum' or 'Alayka' before the word Salamun if
the one who greeted him did not say so. In fact, the recommended precaution is
that the reciprocation must fully conform with the way Salam was initiated.
So if he said: Salamun alaykum, the reply should be Salamun alaykum, and if he
said: As-Salamu alaykum, then the reply should be the same. Similarly, the reply
to Salamum alayka will be Salamun alayka. But if someone initiated Salam saying
Alaykumus Salam, then the answer can be given in any of the phrases.
1147. It is necessary that the reply to Salam is given at once, irrespective of whether one is praying or not. And if, whether intentionally or due to forgetfulness, he delays reply to the Salam, so much that if he gives a reply after the delay, it may not be reckoned to be a reply to that Salam, then he should not reply if he is in namaz. And if he is not in namaz it is not obligatory for him to reply.
1148. A person should reply to a Salam in a way that one who greets him can hear it. However, if he who says salam is deaf, or passes away quickly, then it is necessary to make reciprocation by sign etc., if that would be understood. If that is not possible, then it is not obligatory to respond when one is not praying. And if one is praying, it is not permissible.
1149. It is obligatory that a person who is in namaz, responds to Salam with the intention of greeting. But if he responds with the intention of prayers or blessing, meaning "May Allah bless You", there is no harm.
1150. If a woman or a Na-Mehram or a discerning child, that is, one who can distinguish between good and evil, says Salam to a person in namaz, the person should respond. However, in reply to the Salam by a woman who says Salamun alayka, the person offering prayers can say Salamun alayki, giving Kasrah to Kaf at the end.
1151. If a person in namaz does not respond to Salam, his prayers are in order, though he will have committed a sin.
1152. If a person says Salam to a person in namaz in a mistaken way, such that it cannot be treated as a Salam, it is not permissible to reply to it.
1153. It is not obligatory to give reply to the Salam said in jest, or the Salam of a non-Muslim man or woman who is not a Zimmi (an infidel living under the protection of an Islamic Government). And if he/she is a zimmi, it is sufficient, on the basis of obligatory precaution, to answer saying 'alayka' only.
1154. If a person says Salam to a group of people, it is obligatory for all of them to give a reply. However, if one of them replies, it is sufficient.
1155. If a person says Salam to a group of people, but a person for whom it was not intended gives a reply, it will still be obligatory upon the group to reply.
1156. If a person says Salam to a group among whom one was in namaz, and that person doubts whether Salam was intended for him or not, it will not be necessary for him to give a reply. And if the person offering prayers is sure that he was also intended by the one who greeted, but some one else has made a response, he does not have to reply. But if he is sure that he was among the group for whom Salam was intended, and no one has replied, then he should reply.
1157. It is Mustahab to greet with Salam, and it has been emphatically enjoined that a person who is riding should greet one who is walking, and a person who is standing should greet one who is sitting, and a younger person should greet an elder.
1158. If two persons simultaneously say Salam to each other, each one of them should, on the basis of obligatory precaution, reply the Salam of the other.
1159. When a person is not in namaz, it is Mustahab that his response to the Salam should be more expansive. For example, when one says salamun alaykum, the other should say salamun alaykum wa rahmatullah in reply.