The letter says knowledge of God is shown by keeping his commandments. It contrasts this with someone who claims to know him but does not keep his commandments. See 1 John 2:3–4.
In 1 John 2:1–6, the writer explains why he is writing: to help his readers avoid sin, yet not fall into despair if they do sin. He points to Jesus Christ as the righteous one who speaks for them before the Father and as the effective sacrifice dealing with sin, reaching beyond one group to the whole world. This section continues the line of thought from 1 John 1:5–10, where the writer contrasts honest confession with claims that ignore wrongdoing. After warning against denying sin, he balances that realism with a strong aim: the community should not sin, and yet there is provision when they fail.
The passage holds two truths together: the writer’s goal is that his readers “may not sin,” and yet he assumes sin can still happen (“if anyone sins”). When it does, the help described is not self-justification but Jesus’ active role “with the Father” as a Counselor, and Jesus is explicitly called “the righteous” (verses 1–2).
A careful answer keeps the immediate passage, the book's argument, and the whole-Bible storyline together, so the question is answered in context instead of as a detached idea.
Start with 1 John 2:3-4, then read the surrounding section so the answer stays connected to the passage's flow.
3This is how we know that we know him: if we keep his commandments.
4He who says, "I know him," and doesn`t keep his commandments, is a liar, and the truth is not in him.