Praying two Rak'ah when you enter the mosque

He (sallallaahu alayhi wa sallam) said:

When one of you enters the mosque, let him pray two Rak'ah before he sits

قال ﷺ: "إذا دخل أحدكم المسجد فليصل ركعتين قبل أن يجلس"

قال الحافظ الذهبي: (هذا حديث صحيح، متفق على أن الأمر فيه أمر ندب) تذكرة الحفاظ

١٢٤٥/٤

 

al-Haafiz al-Dhahabi said:

This Hadiith is Sahiih [very authentic] and everyone agrees that the command in this Hadiith is for recommendation [i.e. to pray the two Rak'ah is a recommended act although a command has been issued regarding it].