brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: localectl set-locale keeps English messages with European date formats

Linux
~/tips/tip-linux-localectl-set-locale-lc-time

sudo localectl set-locale LANG=en_US.UTF-8 LC_TIME=nl_NL.UTF-8

Sets English system messages with Dutch-style 24-hour date and time formatting.

I want my servers in English, because error messages in English are the ones you can search for. But I live in Leiden, and a 12-hour clock with the month first is not how I read dates. The system locale can do both at once.

A locale is split into categories. LANG is the default for all of them, and a variable such as LC_TIME overrides one category. localectl writes the system-wide setting, which services use and which every user gets as the default at login:

localectl list-locales
sudo localectl set-locale LANG=en_US.UTF-8 LC_TIME=nl_NL.UTF-8
localectl status

Messages stay in English, and anything that formats dates through the C library now uses the Dutch rules. The locale(7) page puts it simply: LC_TIME governs the formatting of date and time values, and most of Europe uses a 24-hour clock. Be aware that it also means Dutch day and month names in output such as date. If that bothers you, pick another European English locale that your system lists.

The caveats. set-locale only accepts what is installed, so check list-locales first; on Debian and Ubuntu you may have to generate the Dutch locale before it shows up. The change applies to new sessions, so log out and back in. And your own shell can still override it: an LC_ALL in your profile wins over everything, and an SSH client that sends its own LANG and LC_ variables (SendEnv) can replace the server’s choice when the server accepts them.

Further reading: localectl(1) manual page, locale(7) manual page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link