The Prophet ﷺ said, "When one of you enters the mosque, let him pray two units of prayer before sitting down."
حدثنا العباس بن عثمان حدثنا الوليد بن مسلم حدثنا مالك بن أنس عن عامر بن عبد الله بن الزبير عن عمرو بن سليم الزرقي
أن النبي ﷺ قال إذا دخل أحدكم المسجد فليصل ركعتين قبل أن يجلس
Bukhari transmitted it in the Book of Prayer, chapter, "If someone enters the masjid, he should pray two rakahs," h:444, and Muslim in the Book of Prayer of Travelers, chapter on the recommendation of greeting the masjid with two rakahs, etc., h:714, from the hadith of Malik through this same chain.