Making this page since I’ve set up too many computers recently and I forget quickly

System Locale

There are a few environment variables which control system locale parts:

ENV VariableUseRecommended ValueComment
LANGLanguageen_US.UTF-8Not setting this to english will cause some scripts to not work
LANGUAGELanguageen_US.UTF-8Not sure why there are two of these
LC_ADDRESSAddress formattingWhatevery you wantI’ve never seen this used by an application
LC_COLLATECollation (Sorting)CYou can get some exotic bugs when not setting this to C
LC_CTYPEI don’t rememberCYou can get some exotic bugs when not setting this to C
LC_IDENTIFICATIONI don’t rememberWhatevery you wantI’ve never seen this used by an application
LC_MONETARYCurrencies and stuffWhatevery you wantUnsure when this is used
LC_MESSAGESI don’t rememberen_US.UTF-8I’ve had parsing bugs when not set to english
LC_MEASUREMENTI don’t rememberWhatevery you wantUnsure when this is used
LC_NAMEI don’t rememberWhatevery you wantUnsure when this is used
LC_NUMERICHow to write numbersen_US.UTF-8I’ve had bugs when not set to english due to , vs . in numbers
LC_PAPERI don’t rememberWhatevery you wantUnsure when this is used
LC_TELEPHONEI don’t rememberWhatevery you wantUnsure when this is used
LC_TIMEI don’t rememberWhatevery you wantUnsure when this is used

Locale configuration (init / sysV)

## Show active locale
locale

## Show active charmap
locale charmap

## Show available (installed) locales
locale -a

## Change locale (for local use)
export LANG=en_US.UTF-8

## Change locale (for global use)
update-locale LANG=en_US.UTF-8

## Change X11 keyboard layout (for local use)
setxkbmap -layout us -variant intl

## Change X11 keyboard layout (for global use)
sudo dpkg-reconfigure keyboard-configuration

Locale configuration (systemd)

## Show active locale
localectl status

## Show active charmap
locale charmap

## Show available (installed) locales
localectl list-locales

## Change locale
localectl set-locale LANG=en_US.UTF-8

## Change X11 keyboard layout
localectl set-x11-keymap us

Preferrable configuration

  • Use en_US as much as possible. It will avoid bugs and in general work best
  • Best X11 layout is keymap=us, layout=us, variant=altgr-intl