Some of The Most Important Means to Attaining Sincerity in The Path of Seeking Knowledge- by Ibn Jamaa’ah and Shaikh Uthaymeen [rahimahumallaah]
In The Name of Allaah, The Most Merciful, The Bestower of Mercy
Ibnu Jamaa’ah [rahimahullaah] stated about sincerity in seeking knowledge: ”It is to have a good intention in seeking knowledge-seeking the face of Allaah by way of it; acting upon it; reviving the sharee’ah; enlightenment of the heart and (rectification) of its hidden affairs; seeking to get close to Allaah on the Day of Judgement, and putting one’s mind to that which Allaah has prepared for its people of His Pleasure and Great Favours.” [Ref 1]
Imaam Muhammad Ibn Saaleh Al-Uthaymeen (rahimahullaah) said: If one says: Through what can sincerity in seeking knowledge be [attained]? We say: Sincerity in seeking knowledge can be (attained) by making an intention for the following:
 [The intention] to fulfil Allaah’s command because Allaah [The Most High] commanded it (i.e. to seek knowledge). Allaah said: [فَاعْلَمْ أَنَّهُ لَا إِلَٰهَ إِلَّا اللَّهُ وَاسْتَغْفِرْ لِذَنبِكَ- So know (O Muhammad) that La ilaha ill-Allah (none has the right to be worshipped but Allah), and ask forgiveness for your sin’’ (Surah Muhammad Ayah19)].
So Allaah [Glorified and Exalted Be He] strongly urged [a person] towards acquiring knowledge. And strongly urging [someone] towards something necessitates having love for it; being pleased with it and commanding [one] to do it.
 [The Intention] to preserve Allaah’s Sharee’ah. That is because preserving Allaah’s Sharee’ah can be done by way of learning, memorization and writing.
 [The Intention] to protect and defend the Sharee’ah. That is because had it not been for the scholars no one would have protected or defended the Sharee’ah. And due to this we find the likes of Shaikhul Islaam Ibn Taymiyyah and other than him amongst the people of knowledge repelling ahlul bidah and clarifying the falsity of their innovations. We see that they reached a lot of good.
 [The Intention] to follow Muhammad’s [sallal-laahu-alayhi-wasallam] Sharee’ah. That is because it is not possible for you to follow his Sharee’ah until you learn about it. [Ref 2]
Ref 1: Source: Tadh-kirah As-Saami Wal-Mutakallim of Al-Kinaaniy: 67-70. Slightly paraphrased]
Ref 2: Source: Sharh Hilyah Taalib Al’Ilm’ pages16- 17. Slightly paraphrased]