LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Blogs > Notes on Linux
User Name
Password

Notices


I leave notes here that I find particularly worth remembering myself.
Rate this Entry

Remove unwanted locales on Ubuntu / Debian

Posted 10-31-2010 at 04:18 AM by bittner
Updated 11-01-2010 at 09:43 AM by bittner
Tags debian, locale

Sometimes you feel bothered by too many locales (pre)installed on your Debian system. If I run a server I typically want basic stuff on it, so for locales "en_US-UTF8" is enough.

Which locales are installed on my machine?
You can check which locales are generated and configured on your system using the locale command:
  • locale ... list the current locale configuration
  • locale -a ... lists all all locales that were generated on your system
  • locale -a -v ... list all locales and show useful additional information (such as directory names that contain the locale information data files)
The last command from above makes you see that all generated locales are located in /usr/lib/locale/, you may remove any of them if unneeded. Each pack of locale information is a directory containing text files and other directories.

Supported locales
All locales that you want your system to support are listed in the text files in /var/lib/locales/supported.d/. These files have two columns, language tag and character map.
I want my system to know US-English only, so I have only one file there, called en, which contains just a single line:
Code:
en_US UTF-8
Error messages
If error messages are displayed when issuing the locale command, e.g.
Code:
locale: Cannot set LC_ALL to default locale: No such file or directory
make sure the file /etc/default/locale exists and has proper content, such as:
Code:
LANG="en_US"
LANGUAGE="en_US:en"
Get rid of unneeded locale data - Step by step
Now we know all the necessary details to get started with cleaning up our system's locale information:
  1. Edit the locale file(s) in /var/lib/locales/supported.d/, and remove all unneeded locales (one locale per line)
  2. Create and edit /etc/default/locale (see above for an example)
  3. Delete all generated locale data: rm -rfv /usr/lib/locale/*
  4. Re-generate new locales: locale-gen

That's all! Reboot your machine to make your changes take effect. Then run one or more of the locale command examples from above to ensure yourself that the result is as expected.
Code:
~# locale
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
~# 
~# locale -a -v
locale: en_US.utf8      directory: /usr/lib/locale/en_US.utf8
-------------------------------------------------------------------------------
    title | English locale for the USA
   source | Free Software Foundation, Inc.
  address | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    email | bug-glibc-locales@gnu.org
 language | English
territory | USA
 revision | 1.0
     date | 2000-06-24
  codeset | UTF-8
There is a package for Debian/Ubuntu that can take care of removing locales and locale related files (e.g. man pages): localepurge. You can install/run it issueing:
Code:
sudo apt-get install localepurge
Read the man page before using it, though. If you can get your stuff done without it it's probably safer to let go.

References
Posted in Uncategorized
Views 66345 Comments 1
« Prev     Main     Next »
Total Comments 1

Comments

  1. Old Comment
    Please remember that this is not supported by the debian package manager and can break the system badly. I just read this while executing localpurge and stopped cold. The description said that the package manager would not know about it and strange effects could happen, the only way to fix it would be to have to reinstall all Debian packages that provide these locales. I'm really dependent on this server, it needs to run flawlessly, so I must look for another Debian compliant way, just wanted to post this here, to save people that time installing this in the first place. Filed under "don't break Debian"
    Posted 10-21-2020 at 03:34 AM by browny_amiga browny_amiga is offline
 

  



All times are GMT -5. The time now is 01:45 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration