How to Set or Get Regional Format in Terminal

14.0416.04command linelocale

I'm looking for single line terminal commands to:

  • check my current regional format or
  • set the regional format to English US.

Currently to change this I have to go to Settings->Language Support->Regional Formats

(Distro: Ubuntu 14.04 LTS, should preferably also work in 16.04 LTS)

Best Answer

Regional Formats changes the following variables:

LC_NUMERIC
LC_TIME
LC_MONETARY

You can use locale to check the current set format.

ron@ron:~$ locale
LANG=en_US
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=en_US.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_ALL=

If you want to see all the locale available in your system you can use:

ron@ron:~$ locale -a
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8

To change, for example, the date format to US you can use:

LC_TIME=en_US.UTF-8 

To change it permanently:

sudo update-locale LC_TIME=en_US.UTF-8

You can also manually edit the file /etc/default/locale instead of update-locale, if you wish so. Changes will be applied the next time you log-in.

Refer to Locale - Community Help Wiki for more details. man 5 locale will you more options to find-tune any of the formats.