Abu Hurairah reported,

The Messenger of Allah ﷺ said, "When one of you enters the mosque, he should not sit down until he has prayed two rakahs."

Ibn Majah 1012

Sahih

حدثنا إبراهيم بن المنذر الحزامي ويعقوب بن حميد بن كاسب قالا حدثنا ابن أبي فديك عن كثير بن زيد عن المطلب بن عبد الله

عن أبي هريرة

أن رسول الله ﷺ قال إذا دخل أحدكم المسجد فلا يجلس حتى يركع ركعتين

ابن ماجه 1012صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Establishing prayer and the sunnah regarding it
Chapter
Whoever enters the masjid should not sit down until he prays
Numbering
Darussalam 1012
Ibn Majah 1012