Abu Nu’aym reported: Sahl ibn Abdullah, may Allah have mercy on him, said, “If one knows the enemy, one knows his Lord. If one knows himself, one knows his status with his Lord. If one knows his mind, one knows his state between him and his Lord. If one knows sacred knowledge, one knows his journey. If one knows the world, one knows the Hereafter.”
And Sahl was asked about the saying, “Whoever knows himself, knows his Lord.” Sahl said, “Whoever defines himself for the sake of his Lord, his Lord defines him for the sake of himself.”
Source: Ḥilyat al-Awliyā’ 10/201
عن أبي نعيم قال سَهْلَ بْنَ عَبْدِ اللَّهِ رحمه الله إِذَا عَرَفَ الْعَدُوَّ عَرَفَ رَبَّهُ وَإِذَا عَرَفَ نَفْسَهُ عَرَفَ مَقَامَهُ مِنْ رَبِّهِ وَإِذَا عَرَفَ عَقْلَهُ عَرَفَ حَالَهُ فِيمَا بَيْنَهُ وَبَيْنَ رَبِّهِ وَإِذَا عَرَفَ الْعِلْمَ عَرَفَ وُصُولَهُ وَإِذَا عَرَفَ الدُّنْيَا عَرَفَ الْآخِرَةَ
وَسُئِلَ سَهْلٌ عَنْ قَوْلِهِ مَنْ عَرَفَ نَفْسَهُ فَقَدْ عَرَفَ رَبَّهُ قَالَ مَنْ عَرَّفَ نَفْسَهُ لِرَبِّهِ عَرَّفَ رَبَّهُ لِنَفْسِهِ
10/201 حلية الأولياء وطبقات الأصفياء