A remote installed application has some encoding problems and on my local machine it is running fine.

What is the best way to "copy" my locales to the remote machine?

The locales on my personal machine are configured like this:

$ locale
  • 1
    a user-specific locale (for one user) or generally for the whole system? Sep 26, 2012 at 15:46

3 Answers 3


You can set locale manually using update-locale:

sudo update-locale LANG=de_DE.UTF-8 LC_MESSAGES=POSIX

Read the man page for more information.

Alternatively, you can manually change your system's locale entries by modifying the file /etc/default/locale.

For example on a German system, to prevent system messages from being translated, you may use:


Note: changes take effect only after a fresh login.

Source: https://help.ubuntu.com/community/Locale

  • I think update-locale needs sudo. Personally I like your alternative solution, maybe you should make it a primary one. :) Sep 26, 2012 at 15:45
  • updated it!! :)
    – green
    Sep 26, 2012 at 15:47
  • "perl: warning: Setting locale failed." .. How to fix this ?
    – Sliq
    Jan 14, 2013 at 15:43
  • 6
    Run the following command: sudo dpkg-reconfigure locales.
    – green
    Jan 16, 2013 at 11:38
  • @green I have the same issue and dpkg-reconfigure locales seems not setting local in /etc/default/locale. is there a way to apply update-locale for all ?
    – Loenix
    Jul 28, 2020 at 8:44

The easier way

  1. Export all locales into a file

    locale > import

  2. Open file and add export at the start of each line

  3. Make it executable with the command chmod ugo+rx import

  4. Copy to desired profile and execute ./import

  • (a) "Copy to desired profile" -- does this mean to move the file to the home of the user (b) Is this a permanent solution? Sep 27, 2012 at 5:06
  • And what would have been the shell script to write the import on each line ? Jul 26, 2017 at 9:51
  • Didn't work for me. I tried to do it from my computer to another ssh. Jul 26, 2017 at 9:59

There are some recommendations when configuring locales in remote machines

1) In Debian machines (remote machine), run the command (as root):

dpkg-reconfigure locales

On the first screen, select the desired locales. After that you will be prompted to choose which is the default locale. Select "none" (reference: https://wiki.debian.org/Locale#Standard ).

2) Configure your ssh service (/etc/ssh/sshd_config) to accept environment variables from the client: uncomment the line:

AcceptEnv LANG LC_*

Restart you ssh server, logoff and log back in and run the locale command. It must match your local machine's locale

  • 2
    You said "On the first screen, select the desired locales", but I have tested on Ubuntu V14.04.2LTS and all the process is done automatically (Generating locales... ... and later Generation complete.) I get no selection screen. Mar 14, 2015 at 0:02
  • @SopalajodeArrierez did you solve that?
    – Girol
    Feb 13, 2018 at 16:32
  • Well, as for today, I am using v16.04 and, indeed, the "first screen" exists and I can select the desired locales. Maybe it was just a problem with v14. Feb 14, 2018 at 2:26
  • Nice! Sorry about my huge delay. I didn't know how to use this tool that time and forgot about my account since then. Best regards.
    – Girol
    Feb 14, 2018 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.