How to unset a locale variable using localectl?

Under Fedora, I’ve set a custom locale variable value:

localectl set-locale LC_TIME=en_DK.UTF-8

This modified LC_TIME indeed.

Now I’d like to get it back to unset/empty/default state.

How do I do that? Preferably, with the same tool that did the change. Both LC_TIME= and LC_TIME="" throw an error.

Asked By: Anton K

||

localectl can’t unset a locale variable directly, however it does simplify locale variable assignments, clearing LC_ variables whose value equals that of LANG. So you can clear LC_TIME by setting it to match LANG:

localectl set-locale "LC_TIME=$LANG"

If LANG isn’t set in your environment, or doesn’t match the value known to localed, you’ll need to specify it manually; run

localectl

to see the current value assigned to LANG.

systemd uses /etc/locale.conf to store its locale settings; if you can’t get localectl to work, you can edit that file instead. You‘ll need to run systemctl daemon-reload so that the changes are taken into account.

Answered By: Stephen Kitt
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.