So if someone says to you: How does ikhlaas in seeking knowledge come about? It comes about through a (number) of matters:
1 – It is that in doing that (seeking of knowledge), you have as your intention that you are complying with Allaah’s command because Allaah, the Most High, commanded with that (seeking of knowledge). So He said: “Have knowledge that none has the right to be worshipped except Allaah. And seek forgiveness for your sin.” (Soorah Muhammad (47) aayah 19) And he – sall Allaahu ‘alaihi wa sallam – encouraged [us] upon knowledge; and encouraging upon a matter necessitates loving it and being pleased with it and commanding with it.
2 – It is that in doing that, you intend to preserve the Sharee’ah (Islamic legislation) of Allaah, because preserving the Sharee’ah of Allaah occurs through learning, and it comes about through preserving [it] in the chests [of people], and it comes about through writing down, writing down the books.
3 – It is that in doing that, you intend to protect the Sharee’ah and defend it, because were it not for the people of knowledge, then the Sharee’ah would not have been protected and no one would have defended it. And therefore you find, for example, Shaykh ul Islaam ibn Taymiyyah and other than him from the people of knowledge who resisted and blocked the people of innovation and clarified the false and futile nature of their innovations, we see that they (these people of knowledge) attained a great deal of good.
4 – It is that in doing that, your intention is to be following the Sharee’ah of Muhammad – sall Allaahu ‘alaihi wa sallam – because you are not able to follow his Sharee’ah until you have knowledge of this Sharee’ah.
(From The Explanation of the Etiquette of Seeking Knowledge of Shaykh al Uthaymeen, p14, translator Nasser ibn Najam)