Although the 10 commandments were given to Moses, written on stone, on Mt. Sinai, they were not only for Jews. The Jews were to be a living testimony to all nations.

Also, they knew of the commandments before that time. That's how they kept the Sabbath-the 4th commandment.