They are extracted from the text. Obviously, there are differences of opinion about which specific ones are which and that is why some denominations may list them differently than others. It really doesn't matter how they are extracted and numbered. Bottom line is they are all there and there are actually only two that sum them up and Jesus numbered them for us.
Jesus said to him, “'You shall love the Lord your God with all your heart, with all your soul, and with all your mind.' This is the first and great commandment. And the second is like it: 'You shall love your neighbor as yourself.’ On these two commandments hang all the Law and the Prophets.”
Matthew 22:37-40 NKJV
It is also recorded in Mark.
Jesus answered him, “The first of all the commandments is: ‘Hear, O Israel, the Lord our God, the Lord is one. And you shall love the Lord your God with all your heart, with all your soul, with all your mind, and with all your strength.’ This is the first commandment. And the second, like it, is this: ‘You shall love your neighbor as yourself.’ There is no other commandment greater than these.”
Mark 12:29-31 NKJV
If you really think about it, don't murder, adultery, theft, jealousy, envy, and lying all stem from covetousness?