How do I change the LANG or LC_ALL for the entire system without rebooting?

Asked 2 years ago, Updated 2 years ago, 91 views

If you do not configure LANG or LC_ALL in debian, you will get the following perl error just by doing apt-get install.

$sudo apt-get install foo
...
perl:warning:Setting locale failed.
perl:warning:Please check that your locale settings:
    LANGUAGE= (unset),
    LC_ALL=(unset),
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl:warning: Falling back to the standard locale ("C").

Currently, the following shell script is used, but reboot is required.

 if! grep-Fq "LC_ALL"/etc/environment;then
  sed-i's /.*ja_JP.UTF-8UTF-8.*/ja_JP.UTF-8UTF-8/'/etc/locale.gen
  locale-gen
  cat</etc/environment
LANG=ja_JP.UTF-8
LC_ALL=ja_JP.UTF-8
EOF
  source/etc/environment
fi

(en_US.UTF-8 is acceptable.)

Is there any way to prevent the above warning from being issued without rebooting?

Thank you for your cooperation.

http://docs.komagata.org/5227

linux debian

2022-09-30 20:29

1 Answers

In order to avoid rebooting, if you can't do the source/etc/environment already mentioned in the question, why don't you limit the range of environment variables?

The command execution units are as follows:

$LC_ALL=en_US.UTF-8 apt-get install foo

If you then had to "required services need specific locales" instead of command execution units:

  • Make the above changes for each service startup script
  • After creating a dedicated user and configuring the required locale, the service runs by that user

You should be able to use either of the .

(In an environment where multiple services are started, it is not very good for one service to require changes to the locale of the entire system...)


2022-09-30 20:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.