How to Acquire Good Characteristics in Islam
Question

How can I acquire good characteristics?
Praise be to Allah.Importance of good character in Islam 
A good attitude is the characteristic of the best of the messengers and is the best action of the righteous. It is – no doubt – half of religion, the fruit of the efforts of the pious and the practice of the devoted worshipper. Bad characteristics are lethal poison and lead to shameful consequences. 
The Prophet (peace and blessings of Allah be upon him) said: “I have only been sent to perfect good characteristics.” (Narrated by al-Bukhari in al-Adab al-Mufrad (273) and classed as sahih by al-Albani in As-Silsilah As-Sahihah, 45) 
Abu Hurayrah (may Allah be pleased with him) said: The Messenger of Allah (peace and blessings of Allah be upon him) was asked about that which will admit most people to Paradise. He said: “Fear of Allah and a good attitude.” (Narrated by At-Tirmidhi (2004); he said it is sahih gharib. It was classed as sahih by Al-Albani in Sahih At-Tirmidhi.) 
Hence Islam paid a great deal of attention to laying down guidelines for treating diseases of the heart (i.e., spiritual diseases) and ways of acquiring good characteristics, which is regarded as one of the most important duties, because no heart will be free of sicknesses. If the heart is neglected, sicknesses will accumulate. No soul is free of inclinations which, if they are given free rein, will lead it to doom in this world and in the Hereafter. 
This kind of medicine requires profound knowledge of reasons and causes, then it needs hard work to remedy it and set things straight, in order to reach a successful outcome. Allah says (interpretation of the meaning): 
“Indeed he succeeds who purifies his own self.” [Al-Shams 91:9]
The Prophet (peace and blessings of Allah be upon him) used to pray for a good attitude, saying, “O Allah, You have made my outward form beautiful so make my attitude good too.” Narrated by Ibn Hibban in his Sahih (3/239) and classed as sahih by Al-Albani in Irwa’ Al-Ghalil (75). 
How to know your own faults
If a person knows what his shortcomings are he can do something to remedy them, but many people are unaware of their faults and shortcomings. A person may see the speck in his brother’s eye and not see the log in his own. The person who wants to know what his own faults are may do four things: 

He may sit before a Shaykh who has insight into people’s faults and knowledge of the subtlety of some problems and learn from him knowledge, good attitudes and manners.
He may ask a sincere friend who has insight and is religiously committed to keep watch over him and take note of his actions, so that he can draw attention to whatever he dislikes of his attitude, actions, and inward and outward faults. This is what the best and greatest imams of Islam used to do. ‘Umar (may Allah be pleased with him) used to say: “May Allah have mercy on a man who shows me my shortcomings.”
He can learn about his faults and shortcomings from the lips of his enemies, because the eye of one who is resentful will always notice bad things about you. A man may benefit more from an enemy who wants to cause trouble and mentions his faults than from a friend who wants to flatter him by praising him and concealing his faults.
He can mix with people. Everything that he sees as blameworthy among people, he should guard against in his own self, because the believer is the mirror of his fellow believer, and in the faults of others he can see his own faults. It was said to ‘Isa (peace be upon him): “Who taught you?” He said: “No one taught me; I saw the ignorance of the ignorant as something bad and I avoided it.”

How to develop good character
Attitude reflects how a person thinks and the way he is inside. Just as, in general, a person’s outward form cannot be beautiful if only the eyes are beautiful and not the nose, mouth and cheek, and everything must be beautiful in order for the entire outward form to be beautiful, so too there are four requirements of inward beauty which must all be met in order for one’s attitude to be good or beautiful. If all four requirements are met and balanced then a good attitude is acquired, the characteristics of which are: strong knowledge, control of anger, control of desire, and a proper balance between these three aspects. 

With regard to strong knowledge, good and sound knowledge means understanding in such a way that one can see the difference between telling the truth and telling lies in speech, between truth and falsehood in beliefs, between beauty and ugliness in actions. If this strength becomes sound, there will result from it wisdom, and wisdom is the head of a good attitude . 
With regard to strength of anger, its beauty is that it is used in accordance with what is dictated by wisdom. 
The same applies to desire; its beauty and strength should be controlled by wisdom, meaning under the control of reason and Shari`ah. 
With regard to balance, it means proper control of desires and anger, under the control of wisdom and Shari`ah. 

Reason is like a sincere adviser. Justice and balance is power, and it is like one who does what is dictated by reason. Anger is to be subjected to control. 
 The one who acquires and balances these characteristics is a man of good character in general, and from it stem all good qualities. 
No one achieved perfect balance of these four characteristics except the Messenger of Allah (peace and blessings of Allah be upon him); people after him vary in how close or distant they are to him in character. Everyone who is close to him in these characteristics is close to Allah, to the extent that he is close to the Messenger of Allah (peace and blessings be upon him). 
How to achieve perfect balance of these four characteristics
This balance may be achieved in two ways: 

By the blessing of Allah, as part of one's inherent nature 
By acquiring these characteristics through effort and training, i.e., pushing oneself to do the actions dictated by the desired characteristic. 

The Messenger of Allah (peace and blessings of Allah be upon him) said: “Knowledge is acquired by seeking it, and patience is acquired by striving to be patient. The one who strives to attain good will be given it, and the one who strives to protect himself from evil will be protected. (Narrated by al-Khatib and others from the hadith of Abu Ad-Darda’; classed as hasan by Al-Albani.) 

If a person wants to attain the characteristic of generosity, the way to attain that is by pushing himself to do the actions of one who is generous, which is giving away wealth. So he keeps pushing himself and persisting in that, striving against his own inclinations, until that becomes second nature and it becomes easy for him, thus he becomes generous. 
Similarly, if a person wants to attain the characteristic of humility, when he is inclined to be arrogant, the way he does it is by persisting in doing the actions of the humble for a long time, striving and pushing himself until that becomes one of his characteristics, and it becomes second nature to him and easy for him. 

All praiseworthy characteristics that are prescribed in Islam may be acquired in this way. Religious characteristics will never become entrenched in the soul unless the soul gets accustomed to doing all good habits, unless it gives up all bad habits, and unless it persists in doing good deeds like one who loves good deeds and enjoys doing them, and hates bad deeds and is pained by them.  
This may be explained by means of examples: 

The one who wants to become proficient in writing, so that this becomes one of his characteristics and writing beautifully becomes second nature to him, has no other way but to hold in his hand that which the proficient writer holds, and persist for a long time, trying to imitate beautiful hand writing, and keep on doing so until it becomes well established in him, then finally beautiful writing will become second nature to him. 
Similarly, if a person wants to become a faqih, he has no choice but to do what the fuqaha’ do, which is to keep studying issues of fiqh until his heart develops a love of the subject. 
And if a person wants to become generous and refrain from asking people, and become patient and humble, he has to keep on doing the actions of those people until they become second nature to him. He should not despair of attaining those characteristics if he fails to study for one night, for he will not be able to attain it with one night’s study. Perfecting the soul and adorning it with good deeds will not be attained by worshipping for one day, and he will not be deprived of it if he sins for one day. But slacking off for one day may lead to another day, then slowly one becomes accustomed to laziness. 

How to treat your body to rid it of bad characteristics 
The likeness of the soul and the way to treat it to rid it of bad characteristics and make it attain good characteristics is that of the body, when treating it to rid it of disease and bring it good health. 
Although the humours are usually in balance, the stomach may become sick due to food, drink or circumstances. Similarly, everyone is born with a balanced nature, but his parents make him a Jew, Christian or Magian, i.e., by training and teaching one acquires bad characteristics.  
Just as the body is not created perfect in the first place, rather it is made perfect by rearing and food, similarly the soul is also created imperfect but with the potential to become perfect, and it can only be perfected by means of education, discipline and nourishment with knowledge. If the body is sound, the doctor’s role is to show one the way to maintain good health; if it is sick, then the doctor’s job is to restore health. The same applies to the soul; if it is pure and sound then one should strive to preserve it and bring it more strength and acquire more good characteristics; if it is imperfect then one should strive to perfect it and purify it. 
Sickness that causes imbalance in the body can only be treated by its opposite, so if it is caused by cold it is treated with heat and vice versa. Similarly, bad characteristics, which are diseases of the heart, are treated by applying the opposite.  So the remedy for the disease of ignorance is seeking knowledge, and the remedy for the disease of miserliness is pushing oneself to be generous, and the remedy for the disease of arrogance is pushing oneself to be humble, and the remedy for the sickness of eating too much is imposing self restraint. 
Just as it is essential to put up with the bitterness of the remedy and show patience in refraining from what one desires when treating physical sickness, so too it is essential to put up with the bitterness of striving and being patient when treating diseases of the heart; rather it is more important, because one gets rid of physical sickness when one dies, but the sicknesses of the heart – Allah forbid – may persist after death and continue forever and ever. 
These examples show you the way to treat diseases of the heart, and demonstrate that the holistic way is to treat them with the opposite of whatever one is inclined towards and likes. Allah has summed up all of that in His Noble Book, when He said (interpretation of the meaning):
“But as for him who feared standing before his Lord, and restrained himself from impure evil desires and lusts.  Verily, Paradise will be his abode.” [An-Nazi’at 79:40-41] 
How to fulfill what you resolve to do
What matters with regard to striving is fulfilling what one resolves to do. If a person resolves to give up a desire, then he must show patience and persist, because if he gets used to giving up what he resolved to do, that will lead to corruption. If it so happens that he falls short of what he resolved to do, then he must impose some punishment on himself because of that, because if he does not scare himself with that punishment, his evil inclinations will overwhelm him and he will be attracted to indulging in desires, and all his efforts will be spoiled. 
Reference: 
Summarized and adapted from Ihya’ ‘Ulum Ad-Din by al-Ghazali (3/62-98). 
And Allah knows best.