How to set LC_NUMERIC to English permanently?

Solution 1:

Append the value to your ~/.bashrc file:

echo 'export LC_NUMERIC="en_US.UTF-8"' >>~/.bashrc

To make it applicable from the current session of bash, source the ~/.bashrc file:

source ~/.bashrc

Example: Here i am changing from en_US.UTF-8 to C:

$ locale | grep LC_NUMERIC
LC_NUMERIC="en_US.UTF-8"

$ echo 'export LC_NUMERIC="C"' >>~/.bashrc

$ source ~/.bashrc 

$ locale | grep LC_NUMERIC
LC_NUMERIC=C

This will change the locale for only the user running the command, for system wide change you need to add the value to /etc/default/locale, check the added portion below.


You can also add the value to the systmwide locale file, /etc/default/locale, which will be read at start. To put it there:

echo 'LC_NUMERIC="en_US.UTF-8"' | sudo tee -a /etc/default/locale

Or

sudo bash -c 'echo "LC_NUMERIC=\"en_US.UTF-8\"" >>/etc/default/locale'

Solution 2:

Graphical logins do not read shell startup files ( ~/.bashrc, ~/.profile and so on ) by default and also should not because these are bash specific.

So it is better to use /etc/environment for system wide environment settings and ~/.xsessionrc for user specific settings.

PAM should by default read /etc/environment - check that

/etc/pam.d/login /etc/pam.d/sshd /etc/pam.d/su /etc/pam.d/cron

includes the line

session       required   pam_env.so readenv=1

-> https://wiki.debian.org/EnvironmentVariables

Solution 3:

The "official" technique to change locale settings for number formatting system-wide is:

sudo update-locale LC_NUMERIC=en_US.UTF-8

After that, restart your system.

If it still does not work, then probably your graphical desktop environment overwrites the system-wide locale settings. On a personal computer, it is best to configure it so that it does not modify the system-wide locale settings at all. How to do this depends on the desktop environment you use. I made instructions for LXQt for this.

Source: A comment by Ron above. I wanted to turn it into a proper answer as it's the official and most straight-forward technique.