第一次ssh登录上去,遇到这样的问题:
>adduser user
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
perl: warning: Please check that your locale settings:
root@www:~# locale
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_ALL to default locale: No such file or directory
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=
网上google了一下,编辑/etc/default/locale
LANG="en_US.UTF-8"
再执行locale,情况相同。 装一个strace看看。(节选)
open("/usr/lib/locale/en_US.utf8/LC_CTYPE", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en_US/LC_CTYPE", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en.utf8/LC_CTYPE", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/locale/en/LC_CTYPE", O_RDONLY) = -1 ENOENT (No such file or directory)
看来en_US.utf8还没装呢。
网上google一下, 这个 http://romyli.javaeye.com/blog/853426 情况差不多,不过咱们这里情况更惨点,可以说什么locale都没装。
root@www:~# cd /usr/share/locales/
root@www:/usr/share/locales# ./install-language-pack en_USGenerating locales...
en_US.UTF-8... done
Generation complete.
dpkg-trigger: dpkg-trigger must be called from a maintainer script (or with a --by-package option)
同样的方法,装上en_US
退出再重新ssh登录进去,看起来就正常了。
再找了一下,直接用 locale-gen 应该也可以。
root@www:~# locale-gen
Generating locales...
en_US.UTF-8... up-to-date
Generation complete.