The Lord is righteous. (Psalm 11:7) What does righteous mean, though? In the Bible, the words righteous and just are translations of the same word. Righteousness is an expression of God's holy nature. He always does what is righteous or just. His actions toward us are always in perfect agreement with his holy nature. His standard of righteousness is not made up by men outside of God's nature, to which God must conform. So, you cannot read a story in the Bible and say God was unjust or unrighteous in his actions. In Psalm 11, God is righteous even in anger and hatred. He hates the violent and wicked person. (11:5) They are acting contrary to God's holy nature, so he must reject them.
We are righteous when we reflect God's righteous nature. For example, we must abhor violence and wickedness since God does if we are to be righteous. God wants us to be righteous. Jesus taught that those who hunger and thirst after righteousness are blessed. (Matthew 5:6) And if we are hungry for righteousness, we will be satisfied. God will work to make us righteous if we want to be righteous. He will make us "Christ-like". And Christ was completely righteous, being one with the Father. (John 10:30)