3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

特定のLocaleを削除したり、C/POSIXだけにする方法

Last updated at Posted at 2015-03-06

とある検証用に、localeをASCIIだけにして、テストせよと指示されたのですが、追加する方法はよくあっても消す方法は意外と少なくてはまったので記載してみます。

なお、Ubuntu 14.10 のみ検証しています。

1.とりあえずlocale purge

$ sudo apt-get install localepurge

まずこれで不要なロケールが削除されるとあったので試してみましたが、変わった気配なし。

$ locale -a
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX

2.特定のLocaleを指定してpurge

$ sudo locale-gen --purge en_US.iso88591 && echo 'Success!'
$ locale -a
C
POSIX
en_US
en_US.iso88591

減った!!
でもまだなんか残ってる...。

3.いろいろ消したり変えてみたり。

$ sudo mv /usr/lib/locale/locale-archive /tmp/
$ sudo mv /var/lib/locales/supported.d/en /tmp/
$ sudo cp -p /etc/default/locale /etc/default/locale.org
$ sudo vi /etc/default/locale
LANG="C"
$ sudo locale-gen --purge                     
Generating locales...
  en_US.UTF-8... done
Generation complete.

なぜUTF-8...

4.もしかしてバックアップファイルみてる?

$ sudo mv /etc/default/locale.org /tmp/
$ sudo locale-gen --purge
Generating locales...
Generation complete.
$ locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
POSIX

BINGO!

あとはエラーに対応して

$ export LANG=C
$ export LC_ALL=$LANG
$ locale -a
C
POSIX

完成!

参考:
http://askubuntu.com/questions/58191/how-can-i-uninstall-a-locale-via-command-line
http://serverfault.com/questions/604846/locale-gen-with-purge-does-not-work

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?