A great many disconnected reports have been transmitted on this question.
Al-Suhaylī relates:
“Abū Saʿīd b. Abī ʿAmr informed us; Abū ʿAbd-Allāh al-Ṣaffār informed us; Abū Bakr b. Abī al-Dunyā informed us; Isḥāq b. Ismāʿīl informed us; Jarīr informed us; and Abū ʿAbd-Allāh al-Malatī (1) told me:
When Moses was about to part from al-Khidr, Moses said to him, ‘Give me some counsel.’
Al-Khidr replied, ‘Be someone who brings benefit, not harm; be cheerful, not irritable; abandon obstinacy, and do not walk about without genuine need.’
Another route adds: ‘Do not laugh except at something truly remarkable.’ (2)
Wahb b. Munabbih said:
Al-Khidr declared, ‘O Moses, people are punished in this world in proportion to how much their hearts are entangled in it.’
Bishr b. al-Ḥārith al-Ḥāfī said:
Moses asked al-Khidr, ‘Advise me.’
He answered, ‘May Allah unfurl His obedience over you like a covering.’ (3)
Ibn ʿAsākir also cites a marfūʿ (prophetic) ḥadīth on this subject through the chain of Zakariyyā b. Yaḥyā al-Waqār (4), yet he is counted among the most notorious fabricators. The narration states:
‘It was read to ʿAbd-Allāh b. Wahb while I was present. Sufyān said: Mujālid reported from Abū al-Waddāk, from Abū Saʿīd al-Khudrī, from ʿUmar b. al-Khaṭṭāb, who said that the Messenger of Allah—peace and blessings be upon him—said:
“My brother Moses said, ‘My Lord …’ and uttered a certain word. Then al-Khidr came to him as a youth, sweet-scented, clad in spotless white garments with the sleeves rolled up, and said, ‘Peace be upon you and the mercy of Allah, O Moses son of ʿImrān. Your Lord conveys His greeting to you.’
Moses answered, ‘He is Peace and to Him belongs peace. Praise be to Allah, Lord of the worlds, whose favors I cannot count and whose thanks I can render only with His help.’
“Moses then said, ‘I would like you to advise me with words by which Allah will benefit me after you.’
Al-Khidr replied, ‘O seeker of knowledge, the one who speaks is less blameworthy than the one who listens, so do not weary your companions when you address them. Know that your heart is a vessel; look well to what you fill that vessel with. Take what suffices you from this world and cast the rest behind your back, for it is not a home for you, nor a place of lasting abode. It was created only as a provision for the servants and a store of supplies for the Day of Return. Train your soul to patience and you will be delivered from sin.
‘O Moses, devote yourself to knowledge if you truly desire it, for knowledge belongs only to the one who gives himself wholly to it. And do not be a collector of endless information, a compulsive talker, for …’ ”