Abdullah bin Abbas reported,

I was riding behind the Messenger of Allah ﷺ one day when he said, "Young man, let me teach you some words. Be mindful of Allah, and Allah will protect you. Be mindful of Allah, and you will find Him before you. When you ask, ask Allah. When you seek help, seek it from Allah. Know that if the entire nation were to gather together to benefit you with something, they would not benefit you except with something Allah had already written for you. And if they were to gather together to harm you with something, they would not harm you except with something Allah had already written against you. The pens have been lifted and the pages have dried."He said, this is a hasan sahih hadith.

Tirmidhi 2516

Hasan

حدثنا أحمد بن محمد بن موسى أخبرنا عبد الله بن المبارك أخبرنا ليث بن سعد وابن لهيعة عن قيس بن الحجاج قال ح و حدثنا عبد الله بن عبد الرحمن أخبرنا أبو الوليد حدثنا ليث بن سعد حدثني قيس بن الحجاج المعنى واحد عن حنش الصنعاني

عن ابن عباس قال

كنت خلف رسول الله ﷺ يوما فقال يا غلام إني أعلمك كلمات احفظ الله يحفظك احفظ الله تجده تجاهك إذا سألت فاسأل الله وإذا استعنت فاستعن بالله واعلم أن الأمة لو اجتمعت على أن ينفعوك بشيء لم ينفعوك إلا بشيء قد كتبه الله لك ولو اجتمعوا على أن يضروك بشيء لم يضروك إلا بشيء قد كتبه الله عليك رفعت الأقلام وجفت الصحف قال هذا حديث حسن صحيح

الترمذي 2516حسن
Contents
Reference
Commentary
Ayat
Collection
Jami Tirmidhi
Book
Description of the Resurrection, softening of hearts, and piety from the Messenger of Allah ﷺ
Chapter
Hadith of Hanzala
Numbering
Darussalam 2516
Tirmidhi 2516