Allah Subhanahu wa T'ala says in the Holy Quran:
وَلَقَدْ آتَيْنَا لُقْمَانَ الْحِكْمَةَ أَنِ اشْكُرْ لِلَّهِ وَمَن يَشْكُرْ فَإِنَّمَا يَشْكُرُ لِنَفْسِهِ وَمَن كَفَرَ فَإِنَّ اللَّهَ غَنِيٌّ حَمِيدٌ
وَإِذْ قَالَ لُقْمَانُ لِابْنِهِ وَهُوَ يَعِظُهُ يَا بُنَيَّ لَا تُشْرِكْ بِاللَّهِ إِنَّ الشِّرْكَ لَظُلْمٌ عَظِيمٌ
وَوَصَّيْنَا الْإِنسَانَ بِوَالِدَيْهِ حَمَلَتْهُ أُمُّهُ وَهْنًا عَلَى وَهْنٍ وَفِصَالُهُ فِي عَامَيْنِ أَنِ اشْكُرْ لِي وَلِوَالِدَيْكَ إِلَيَّ الْمَصِيرُ
وَإِن جَاهَدَاكَ عَلى أَن تُشْرِكَ بِي مَا لَيْسَ لَكَ بِهِ عِلْمٌ فَلَا تُطِعْهُمَا وَصَاحِبْهُمَا فِي الدُّنْيَا مَعْرُوفًا وَاتَّبِعْ سَبِيلَ مَنْ أَنَابَ إِلَيَّ ثُمَّ إِلَيَّ مَرْجِعُكُمْ فَأُنَبِّئُكُم بِمَا كُنتُمْ تَعْمَلُونَ
(31:12) We had bestowed wisdom on Luqman that he may be grateful to Allah. Whoever is grateful, his gratefulness is for his own good, and whoever is ungrateful, then Allah is indeed Self-Sufficient and Self-Praiseworthy.
(31:13) Remember the time when Luqman was admonishing his son, saying, "My son, join not another as an associate with God: the truth is that joining associates (with God) is a grave iniquity."
(31:14) And the fact is that We have Ourself enjoined on man to recognize the rights of his parents: his mother bore him in her womb with weakness upon weakness and his weaning took two years. That is why We admonished him to the effect: "Give thanks to me and to your parents: to Me you have to return.
(31:15) But if they press you to join with Me another about whom you have no knowledge, do not obey them at all. Treat them kindly in the world, but follow the way of him who has turned to Me. Then to Me will all of you return; then I shall tell you what you had been doing.
(31:16) (And Luqman had said:) "My son, even if a thing be equal to a grain of mustard seed and hidden in a rock, or in the heavens, or in the earth, Allah will bring it forth. He is Knower of subtleties and is All-Aware.
(31:17) O my son. establish the Salat, enjoin good, forbid evil and bear with fortitude every affliction that befalls you. These are the things which have been strictly enjoined.
(31:18) And do not speak to the people with your face turned away, nor walk proudly. on the earth, for Allah does not love any self-conceited, boastful person.
(31:19) Be moderate in your gait, and lower your voice, for the most disagreeable of all voices is the braying of the asses."
Some commentary follows:
1. Thanking Allah
The very first demand of the wisdom and knowledge, insight and sagacity, granted by Allah was that man should have adopted the attitude of gratefulness and obedience before his Lord, and not of ingratitude and thanklessness. And this gratefulness should not have merely been lip-service but expressed and translated in thought and word and deed. One should have the conviction in the depths of one's heart and mind that whatever one has got, has been given by God. One's tongue should always be acknowledging the favors of God; and practically also one should be trying to prove by carrying out His Commands, by avoiding sins, by striving to achieve His good-will, by conveying His blessings and favours to His servants and by fighting those who have rebelled against Him that one is really a grateful servant of one's God.
2. Ungrateful Harm themselves
The one who is ungrateful and unbelieving, his unbelief is harmful to his own self. Allah does not lose anything. He is Independent and does not stand in need of anyone's gratitude. The gratitude of someone does not add anything to His Godhead, nor does anyone's ingratitude and disbelief change the factual reality that whatever the servants have got, has been granted by Him. He is Self-Praiseworthy whether someone praises Him or not. Every particle in the universe bears testimony to His Perfection and Beauty, His Creativity and Providence, and every creature is paying homage to His glory perpetually.
3. Luqman's first advice to his son: No to Polytheism
This particular admonition from the wisdom of Luqman has been cited in verse 13 for two reasons:
(a) He gave this admonition to his son, and obviously, no one can be insincere to one's own children. A person may deceive others, may behave hypocritically towards them, but no one, not even a most depraved person, will try to deceive and defraud his own children. Therefore, Luqman's admonishing his son thus is a clear proof of the fact that in his sight shirk was indeed the most heinous sin, and for that very reason he first admonished his dear son to refrain from this iniquity.
(b) The second reason for this narration is that many parents from among the disbelievers of Makkah were compelling their children to turn away from the message of Tauhid being preached by the Holy Prophet Muhammad (upon whom be Allah's peace) and remain steadfast on the creed of shirk, as is being stated in the following verses. Therefore, those foolish people are being told, as if to say, The well-known sage of your own land had wished his children well by admonishing that to avoid shirk, now you should judge it for yourself whether you are wishing your children well or ill when you compel them to follow the same creed of shirk.
4. Shirk (Polytheism) is a grave iniquity
Zulm means to deprive someone of his right and to act unjustly. Shirk is a grave iniquity because man sets up such beings as equals with his Creator and Providence and Benefactor as have no share whatever in creating him, nor in providing for him, nor in bestowing the blessings on him, which he is enjoying in the world. There could be no greater injustice than this. The Creator's right on man is that he should worship Him alone, but he worships others and so deprives Him of His right. Then, in whatever he does in connection with the worship of others than Allah, he exploits many things, from his own mind and body to the earth and heavens, whereas, all these things have been created by Allah, the One. and man has no right to use any of them in the worship of any other than Allah. Then, the right of man's own self on him is that he should not debase and involve it in punishment. But when he worships others than his Creator. he debases his self as well as makes it deserving of the punishment. Thus, the entire life of a mushrik becomes Zulm in every aspect and at all times and his every breath becomes an expression of injustice and iniquity.
5. Tusa'ir
In verse 18, "And do not speak to the people with your face turned away"
Tusa'ir in the original is from se'ar, a disease in the camel's neck due to which it keeps its face turned to one side. The idiom implies the attitude of a person who shows arrogance and vanity, turns his face away and treats others with scant respect.
6. Mukhtal and Fakhur
In verse 18, "Allah does not love any self-conceited, boastful person."
Mukhtal in the original implies a person who has an over-high opinion of himself, and fakhur is the one who boasts of his superiority over others. A man becomes haughty and arrogant and vain in his gait only when he is puffed up with pride, and wants that others should feel his superiority.
7. Be moderate in your gait
According to some commentators it means: 'Walk neither fast nor slow but at a moderate pace :" but the context shows that here the pace or the rate of walking is not the question. There is nothing morally wrong with a fast or a slow pace in itself, nor can there be a rule made for it. When a man is in a hurry. he has to walk fast, and there is nothing wrong if one walks slow when walking for pleasure. Even if there is a standard for the moderate pace, it cannot be made a law for every person at all times. What is actually meant by this is to reform the state of the self under which a person walks haughtily. The haughtiness and arrogance of a person inevitably manifests itself in his gait and style of walking, which shows the state of his mind and also the cause of his pride and haughtiness. Wealth, authority, beauty. knowledge, power and such other things cause a man to became proud and vain, and each of these gives him a special style of gait. Contrary to this, manifestation of humility in the gait is also the result of one or the other morbid mental state. Sometimes the hidden conceit of the self of a man takes on the form of ostentatious humility, piety and godliness and this is shown by his gait; and sometimes man really feels so embittered by the frustrations of the world that he adopts a sick man's gait. What Luqman means to say is this: "Avoid these states of the mind and self and walk the gait of a simple, honest and noble person, which neither shows any vanity and haughtiness nor weakness nor ostentatious piety and humility."
The taste of the Holy Prophet's great Companions in this regard can be judged from a few instances. When Hadrat Umar once saw a man walking with his head hung down, he shouted out to him, saying, "walk with your head raised up. Islam is not sick. "He saw another person walking like a weak, sick man, and said, wretch! Do not sully our religion! " Both these incidents show that in the sight of Hadrat 'Umar religious piety did not at all require that one should walk cautiously. like the sick man and show undue humility by one's gait. Whenever he saw a Muslim walking such a gait, he would have the apprehension that it would misrepresent Islam and would depress the other Muslims. A similar incident was once met with by Hadrat 'A'ishah. She saw a person walking as if run down and exhausted. She asked what was the matter. It was said, 'He is one of the reciters of the Qur'an (i.e., a person who remains engaged in reciting and teaching the Qur'an and in worship)." At this, she said, 'Umar was the chief of the reciters of the Qur'an, but as it was, he would walk with a firm foot, and he would speak with force and strength, and he would give a good beating if he had to."
8. lower your voice, for the most disagreeable of all voices is the braying of the asses
This does not mean that one should always speak in a low voice and should never raise one's voice. By citing the braying of the asses, it has been clearly indicated what sort of the tone and voice in speech is meant to be discouraged. One kind of lowness and loudness, roughness and softness, of the rove and voice is that which is needed under natural and genuine requirements. For example, when speaking to a man close at hand, or to a small group of the people, one would speak in a low voice, and when speaking to a man at a distance or to a large number of the people, one would inevitably have to speak loudly. Similar is inevitably the difference in tones depending on the occasion and situation. The tone of praise has to be different from the tone of condemnation. and of the expression of goodwill from that of indignation. This thing is in no way objectionable. Nor does the admonition of Luqman imply that one should always speak in a soft and low voice and tone regardless of the occasion and requirement. What is objectionable is that one should shout oneself hoarse and produce a voice like the ass's braying in order to bully and debase and browbeat the other person.
(Tafseer from Tafheemul Quran)