A good deed is that which is pleasing to Allah the Almighty, and it combines two things;
The first: that it be in accordance with Islamic law,
The second: that it be intended to please and obey Allah,
So, if the deed lacks one or both of these, it is not pleasing to Allah, and therefore there is no reward for it.
The Almighty said:
فَمَن كَانَ يَرْجُوا۟ لِقَآءَ رَبِّهِۦ فَلْيَعْمَلْ عَمَلًا صَـٰلِحًا وَلَا يُشْرِكْ بِعِبَادَةِ رَبِّهِۦٓ أَحَدًۢا
So, whoever hopes for the meeting with their Lord, let them do good deeds and associate none in the worship of their Lord. [Al Kahf 18: 110]
What is meant by righteous deeds is correct deeds, i.e., in accordance with Islamic law, and purely for the sake of Allah the Almighty. The good deed is represented in the acts of worship, obedience and obligations that Allah commanded his servants to do, and also represents the reason for their creation and existence on the earth.
To Precede in Greeting
Greeting brother Muslims is one of the Islamic practices which are a hallmark of a Muslim and its merits have been explained in many Ahadith. e.g.
قال رسول الله صلى الله عليه وسلم: إن أولى الناس بالله من بدأهم بالسلام
ورواه الترمذي عن أبي أمامة رضي الله عنه: قيل: يا رسول الله، الرجلان يلتقيان، أيهما يبدأ بالسلام؟ قال: ”أولاهما بالله تعالى”
The Messenger of Allah (ﷺ) said, “The person nearest to Allah is one who is the first to offer greeting.” [Abu Dawud, the narration in Tirmidhi is: The Messenger of Allah (ﷺ) was asked: “O Messenger of Allah! When two persons meet, who should greet the other first?” The Messenger of Allah (ﷺ) said, “The person nearest to Allah (i.e., one who is more obedient and therefore closer to Allah will say: As-Salam first).”
It is not necessary to greet only those with whom one is acquainted; greeting strangers who are known to be Muslims is a matter of great merit. Our holy Prophet ﷺ was asked as to which action are good for Muslims. Among the actions which our holy Prophet ﷺ enumerated was this:
“You should greet people whether you know them or not” (Bukhari and Muslim)
It is reported about Abdullah bin Umar RA that sometimes he went out of the house only to greet any Muslims he met and thus to increase his merit. (Muwatta Imam Malik)
The correct interpretation of this hadith, however, is that one should greet others, though not everyone one sees because it is impossible and it might also be embarrassing for others. (Al Adab al Shariah, li ibn Muslih page 422, volume 1)
It is also a sunnah to greet the family when entering the house. Our holy Prophet ﷺ instructed his personal servant Anas RA as follows: “0 son! When you enter (your) house, greet your family members; this act shall be of benefit for both you and your family members” (Tirmidhi)
Even when entering an empty house, one should greet with the intent that angels are being greeted. Abdullah ibn Umar RA used to say:
السلام علينا و علي عباد الله الصالحين
On such occasions (Al Adab al Shariah li ibn Muslih, p.424, vol.1)
The Hadith also urges the Muslims to clearly speak out the greeting so that it may be heard and understood.
Although the Sunnah of greeting is fulfilled by saying “السلام عليكم” but adding “wa Rahmat ullahi wa barakatuh” earns more merit.
جاء رجل إلى النبي صلى الله عليه وسلم فقال: السلام عليكم، فرد عليه ثم جلس، فقال النبي صلى الله عليه وسلم: “عشر” ثم جاء آخر، فقال: السلام عليكم ورحمة الله، فرد عليه فجلس، فقال: “عشرون” ثم جاء آخر، فقال: السلام عليكم ورحمة الله وبركاته، فرد عليه فجلس، فقال: “ثلاثون
‘Imran bin Husain RA reported: A man came to the Prophet (ﷺ) and said: “As-Salamu ‘Alaikum (May peace be upon you). The Messenger of Allah (ﷺ) responded to his greeting and the man sat down. The Prophet (ﷺ) said, “Ten (meaning the man had earned the merit of ten good deeds).” Another one came and said: “As-Salamu ‘Alaikum wa Rahmatullah (May peace be upon you and the Mercy of Allah).” The Messenger of Allah (ﷺ) responded to his greeting and the man sat down. The Messenger of Allah (ﷺ) said, “Twenty.” A third one came and said: “As-Salamu ‘Alaikum wa Rahmatullahi wa Barakatuhu (May peace be upon you and the Mercy of Allah and His Blessings).” The Messenger of Allah (ﷺ) responded to his greeting and the man sat down. The Messenger of Allah (ﷺ) said, “Thirty.” [Abu Dawud and Tirmidhi].