This depends on what you mean. If you predominantly use Metric or Imperial then you want to set that from Config menu then Native Units. That will mean that all units will default to what you have chosen and you will have to make sure your steps per unit are also in that unit ( Inch or mm).
If however you are just asking how to run metric code on a machine with Imperial Native units, or vice versa, then G20 or G21 at the start of your code will do that.
Hood