The Prince of this world has been cast out
Christ’s miracles were ordained to manifest his divinity. However, this had to remain hidden from the demons, otherwise the mystery of the passion would have been hindered by them: “If they had known the Lord of glory, They would not have crucified him,” (1Cor 2,8). It would seem, then, that Christ should not work miracles over the demons… Yet the prophet Zechariah
predicted these wonders when he cried out: “I will take away the spirit of uncleanness,” (Zec 13,2). Indeed, Christ’s miracles were proofs demonstrating the faith he taught. Now, through the power of his divinity, was it not fitting for him to do away with the demons’ power in those who would believe in him, according to Saint John’s words: “Now the ruler of this world is driven out”? (Jn 12,31). Thus it was fitting that, among his other miracles, Christ should deliver from demons those men who were possessed by them… Besides, Saint Augustine writes: “Christ made himself known to the demons for as long as he wished to do so, and he wished to do so for as long as it was necessary… through certain material consequences of his power.” At the sight of his miracles the devil came to believe through conjecture that Christ was the Son of God: “the demons… knew he was the Christ” says Saint Luke (Lc 4,41). If they confessed he was Son of God, “it was by way of conjecture rather than by way of knowledge,” Saint Bede comments. As for the miracles Christ accomplished when he cast out demons, he did not do these for their own usefulness but for that of men, so that they might give glory to God. That is why he prevented the demons from speaking about anything affecting his praise. Saint John Chrysostom observes: “It was not fitting that the demons should take to themselves the glory proper to the function of the apostles, nor that lying tongues should preach the mystery of Christ.”
This underscores the truth of how God is revealed to us. Christ said that no one can know the Father but those to whom He is revealed by the Son. The reasoning abilities of created beings (whether human or pure spirit) are insufficient to "know" God. God has to be revealed to us, and we have to accept this revelation through the faith that is also given from God. It makes sense that Satan did not truly know who Jesus was when tempting him in the desert. It's also apparent that the demon in Mark 1:24 and Luke 4:34 is limited in knowledge of Christ since it refers to Jesus as "the Holy One of God" - which is truth, but not the whole truth. Christ IS God. In a similar way, Peter reaches that peak of human capacity to understand when in John 6:68-69 he too calls Jesus "the Holy One of God". But Peter's admission is one of total abandonment to Jesus in humility towards the mystery of the Eucharist that just caused so many disciples to leave Jesus in disgust. This humility in asking for and receiving the gift of Faith is the foundation (the Rock) on which the Father places the highest revelation of Truth in Matthew 16:
 Now when Jesus came into the district of Caesare'a Philip'pi, he asked
his disciples, "Who do men say that the Son of man is?"  And they said,
"Some say John the Baptist, others say Eli'jah, and others Jeremiah or one of
the prophets."  He said to them, "But who do you say that I am?"  Simon
Peter replied, "You are the Christ, the Son of the living God."  And Jesus
answered him, "Blessed are you, Simon Bar-Jona! For flesh and blood has not
revealed this to you, but my Father who is in heaven.  And I tell you, you
are Peter, and on this rock I will build my church, and the powers of death
shall not prevail against it.  I will give you the keys of the kingdom of
heaven, and whatever you bind on earth shall be bound in heaven, and whatever
you loose on earth shall be loosed in heaven."
When the demons claim knowledge of Jesus it is out of self-interest and with hatred - almost an attempt to control their enemy by showing off their special knowledge of who Christ is. This is an easy sin for intellectuals in the Church to fall into, as B16 has pointed out.