The Messenger of Allah ﷺ said, "Among the things that continue to reach a believer from his deeds and good works after his death are knowledge he taught and spread, a righteous child he left behind, a copy of the Quran he passed on as inheritance, a mosque he built, a lodging he built for the wayfarer, a stream he caused to flow, or charity he gave from his wealth while in good health during his lifetime. These will reach him after his death."
قال رسول الله ﷺ: إن مما يلحق المؤمن من عمله وحسناته بعد موته: علما علمه ونشره، وولدا صالحا تركه، ومصحفا ورثه، أو مسجدا بناه، أو بيتا لابن السبيل بناه، أو نهرا أجراه، أو صدقة أخرجها من ماله في صحته وحياته، يلحقه بعد موته.
Ibn Majah (242) narrated it from Muhammad bin Yahya, who said, Muhammad bin Wahb bin Atiya told us, who said, Walid bin Muslim told us, who said, Marzuq bin Abu Huzayl told us, who said, Zuhri told me, who said, Abu Abdullah Aghar told me, from Abu Hurairah, and he related it.Ibn Khuzayma graded it sahih (2490), and narrated it through the route of Walid bin Muslim. Munziri graded it hasan in Targheeb wat-Tarheeb (123), by way of Ibn Majah.Its chain is hasan, because of Marzuq bin Abu Huzayl Thaqafi. Abu Hatim said about him, I heard Duhaym say, He is sahih in his hadith from Zuhri. Abdul-Rahman bin Abu Hatim said, on the authority of his father, His hadith is acceptable. As for Ibn Hibban, he went to an extreme and said, He alone transmitted objectionable reports from Zuhri that have no basis, so his errors multiplied, and consequently no argument can be made from what he alone transmitted.As for what Ibn Majah narrated (243) through another route, from Hasan Basri, from Abu Hurairah, with the wording, "The best charity is for a man to learn some knowledge and then teach it to his Muslim brother," this is daif. Its chain contains Yaqub bin Humayd bin Kasib, who is daif, and Hasan Basri did not hear directly from Abu Hurairah.