Sunan Ibn Majah, Volume 5, Book 37, Hadith 4114 (DarusSalam) ⓘ
It was narrated that Ibn ‘Umar said: “The Messenger of Allah took hold of some part of my body and said: ‘O ‘Abdullah, be in this world like a stranger, or one who is passing through, and consider yourself as one of the people of the graves.’”
حَدَّثَنَا يَحْيَى بْنُ حَبِيبِ بْنِ عَرَبِيٍّ، حَدَّثَنَا حَمَّادُ بْنُ زَيْدٍ، عَنْ لَيْثٍ، عَنْ مُجَاهِدٍ، عَنِ ابْنِ عُمَرَ، قَالَ أَخَذَ رَسُولُ اللَّهِ ـ صلى الله عليه وسلم ـ بِبَعْضِ جَسَدِي فَقَالَ " يَا عَبْدَ اللَّهِ كُنْ فِي الدُّنْيَا كَأَنَّكَ غَرِيبٌ أَوْ كَأَنَّكَ عَابِرُ سَبِيلٍ وَعُدَّ نَفْسَكَ مِنْ أَهْلِ الْقُبُورِ " .
also referenced under: Hadith 4114 (Reference) & Book 37, Hadith 4253 (In-Book)