John shifts a bit from a negative indicator (those in God do not sin), to a positive one: those who know God obey His commands. It harkens back to the statement in 1:6. Walking with God is not just about avoiding darkness, we also seek out and remain in the light. We don’t just avoid disobedience, we attempt to obey.
“Keep His commandments.” Much as with all the discussion of avoiding sin, this is not a claim of perfection. Just as John spoke of avoiding sin as a goal to aim for—a motivation driven by assistance and forgiveness from God to those who recognize their need for help—so this talk of obedience is more about intention rather than ability. It is more about devotion.
Not, “it’s the thought that counts.” The follower of Jesus truly does obey what they hear and learn in their walk with God. They may stumble and fall, but they devote themselves to walking with Jesus and are not content to merely claim to try.
Consider someone with a passionate drive or interest for a hobby like a sport or an art. Such a person is going to devote themselves—their time and money etc.—to that passion. They will not likely be perfect at it, or even be the best the world has ever seen, but they will grow in knowledge, ability, and skill. That is the “following” that is meant here. A person passionate about walking in the light will grow in their knowledge of God, His passions, and His desires for their life. They will hear and understand His commands. The result will not be perfection, but rather growth.
And that is specifically what John means here. In verse 5, he says that following God results in His love being fulfilled in us. We grow and are being perfected in God’s love. This is not a following of commands the way the Pharisees of Jesus’ day did; not a legalism that compiles a list of rules and then takes pride in keeping all the rules. Jesus consistently condemned that attitude and practice. Here we see a people who grow in understanding and implementing God’s love in the world.
After all, the goal here is not to become more religious and self-righteous, but to be more like Jesus. Jesus was selfless. Jesus did everything that the Father wanted. We are to walk (i.e. live) as our Savior did.