I have a need to reduce the size of the locale-archive file on some of my RHEL6 systems.

Here is that file on my system:

[root@-dev-007 locale]# ls -l
total 96800
-rw-r--r--. 1 root root 99158704 Sep  9 15:22 locale-archive
-rw-r--r--. 1 root root        0 Jun 20  2012 locale-archive.tmpl

So I did this ...

[root@-dev-007 locale]# localedef --list | grep zh_CN

... so I figured I could get rid of zh_CN like so ...

[root@-dev-007 locale]# localedef --delete-from-archive zh_CN

... and I can see zh_CN does not get listed anymore like so ...

[root@-dev-007 locale]# localedef --list | grep zh_CN

... but the size of the locale-archive does not get smaller ...

[root@-dev-007 locale]# ls -l  
total 96800
-rw-r--r--. 1 root root 99158704 Sep  9 17:16 locale-archive
-rw-r--r--. 1 root root        0 Jun 20  2012 locale-archive.tmpl

... is there something else I need to do?

3 Answers 3


You can first remove all unneeded locales by doing:

$localedef --list-archive | grep -v -i ^en | xargs localedef --delete-from-archive

Where ^en can be replaced by the locale you wish to keep



If this gives you an error similar to

/usr/sbin/build-locale-archive: cannot read archive header

Then try this

$mv /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl

If that still fails, check your version. According to this page newer versions don't have the necessary files to rebuild the archive in order to save space. You'll need to run

yum reinstall glibc-common

In later releases of Red Hat Enterprise Linux, you may use dnf, a similar application.

  • 4
    I noticed though that I loss my ssh connection to the host when I execute build-locale-archive ... any way of preventing this? Commented Sep 10, 2013 at 22:23
  • 2
    I'd be careful attempting this. Broke my CentOS server and took me 30 mins to figure out a solution. unix.stackexchange.com/questions/246705/…
    – Jay Brunet
    Commented Dec 1, 2015 at 23:02
  • dnf in rhel??? Surely you mean yum ;-)
    – Dani_l
    Commented May 7, 2016 at 13:53
  • 1
    build-locale-archive forces to logout but it seems to work Commented Oct 24, 2023 at 10:05

On Amazon Linux

  1. Delete the unused archives from the locale-archive. This command deletes all except the ones beginning with en.

    localedef --delete-from-archive $(localedef --list-archive | grep -v -i ^en | xargs)
  2. Copy the locale-archive (with removed locales) file to be the new locale-archive.tmpl file

    cp /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl
  3. Run build-locale-archive


Note: If you run build-locale-archive it zeros out the .tmpl file after each run and when you run it again you will see the error:

build-locale-archive: cannot read archive header

You can get a copy of the locale-archive.tmpl file either by copying the current locale-archive to locale-archive.tmpl or by downloading and unpacking glibc-common. If you use the default locale-archive.tmpl file from the glibc-common RPM and run build-locale-archive against it, it will create a full (~102MB) locale-archive. You need to repeat the above steps to get the smaller size archive.

In the above case deleting all locales except the en_* ones my locale-archive went from 102MB down to 3.4MB


Mildly easier way,

cp /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive.tmpl
build-locale-archive --install="en"

Where "en" is a colon separated list, e.g. "de:en:ja"

I've been trying to find a way to do this to a file not in /usr/lib/locale but so far all attempts fail. Probably need another thread for that problem though.

  • i can't comment on the main question. This question is specific to RHEL6 and the solutions work through RHEL8. But in RHEL9 (like Fedora 32+), build-locale-archive is removed and the archive file is 200MB and I haven't yet found a way to reduce it. It is possible it is not needed because there are separate RPM installs for just the english pack, but I don't know that all applications know to reference the individual locales if the locale-archive file is missing.
    – vtwaldo21
    Commented Sep 9, 2023 at 14:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .