How to override the system locale on a single command?

When helping someone we often ask them to show the output of a command eg:

sudo fdisk -l | pastebinit

If the user is not using an English locale, the output may be in a foreign language:

Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 huvuden, 63 sektorer/spår, 91201 cylindrar, totalt 1465149168 sektor

This complicates support. How can one run a command with an override on the system locale to get English output?


The environment variables to override with the locale you wish to use are LANG, LC_ALL, and LANGUAGE. Some apps will handle some of these differently, but generally just setting LANG should work. You can run a command in the terminal with it, like LANG=es_ES locale. The locale command will show the current environment variable settings for your locale.