System and processes

The locale command

Shows the session language and formats: numbers, dates and sort order.

Most useful options

-aLists all the locales available on the system
-mLists the available character sets (charmaps)
-cWrites the category name before its values, such as LC_TIME
-kShows each value with its name, as name="value"
-vAdds extra information for some combinations, such as locale -a -v
-VShows the program version and exits

Copy-ready examples

$ localeshows the setting of each category in your session.
$ locale -k decimal_pointshows the decimal separator with its name. With the C setting it is the dot.

Example output

decimal_point="."
$ locale -a | grep -i utf-8 | head -n 3lists a few installed locales that use UTF-8.
$ locale -ck date_fmtwrites LC_TIME before the date format, so you know which category it belongs to.
$ LC_ALL=C sort nombres.txtsorts with the C setting, byte by byte: uppercase comes before lowercase.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
locale: Cannot set LC_ALL to default locale: No such file or directoryLC_ALL points to a locale the system does not have generated, so loading it fails and locale reports it.Check the available ones with locale -a, set LC_ALL to a valid one or remove it with unset LC_ALL.

Typical mistakes

  • LC_ALL overrides all the other LC_* variables and LANG too. If it is set, changing LANG has no effect.
  • A wrong setting can make accents look wrong or make sort order unexpected.
  • If a locale does not appear in locale -a, it is not generated on the system and cannot be used.

Differences from similar commands

  • localectl: queries and changes the system locale through systemd, instead of your session.
  • env: shows all environment variables, LANG and LC_* included, without interpreting them.

Related commands

FAQ

What is LC_ALL?

The variable that, if set, overrides all the other LC_ variables and LANG too.

Do I need to be an administrator to use locale?

No. locale only reads the variables of your session; changing the system locale is a different task.

Why does sort order differ between my machine and another one?

Because the order depends on the LC_COLLATE category. With LC_ALL=C it sorts by bytes and gives the same result on any machine.

More System and processes commands

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course