In the console to input dpkg-reconfigure locales,a gui jump out ,i select en_HK.UTF-8 as my target ,click enter.

enter image description here

dpkg-reconfigure locales
Generating locales (this might take a while)...
en_HK.UTF-8... done

How to automate the whole process into one command ?


One command:

sudo update-locale LANG=en_HK.UTF-8

Easy day :)

  • 2
    update-locale is for updating /etc/default/locale. In other words it's something else... – Gunnar Hjalmarsson Oct 9 '15 at 16:00

What worked charm for me was a combination between the @DevRobot's and the @Gunnar Hjalmarsson's answers (run as root). EDIT: Added some improvements to avoid annoying errors:

update-locale "LANG=en_HK.UTF-8"
locale-gen --purge "en_HK.UTF-8"
dpkg-reconfigure --frontend noninteractive locales

Another possibility (that works even better) is through the debconf-utils utilities and debconf-set-selections (run as root):

echo "locales locales/default_environment_locale select en_HK.UTF-8" | debconf-set-selections
echo "locales locales/locales_to_be_generated multiselect en_HK.UTF-8 UTF-8" | debconf-set-selections
rm "/etc/locale.gen"
dpkg-reconfigure --frontend noninteractive locales

Hope this might help.


I would probably run:

sudo locale-gen --purge

That regenerates all the locales for your installed languages.


This gist had the solution for me:

sudo sed -i '/^#.* en_US.* /s/^#//' /etc/locale.gen
sudo locale-gen

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.