これは、なにをしたくて書いたもの?
前に、こんなエントリーを書きました。
Vagrantで使っているUbuntu Linux 20.04を日本語化する - CLOVER🍀
Ubuntu Linux 22.04 LTSもリリースされましたし、VagrantのBoxも出ているのでこちらのエントリーと同様に日本語化から行ってみたいと
思います。
使用するVagrantのBoxは、こちらです。
Vagrant box generic/ubuntu2204 - Vagrant Cloud
自分がPCで主で使っているLinuxはUbuntu Linux 20.04 LTSのままなのですが、まずはVMからと。
PCで使っている方は、そのうちアップグレードするかどうか…ちょっと悩んでいます。
環境
今回の環境は、こちら。
$ vagrant version Installed Version: 2.2.19 Latest Version: 2.2.19 You're running an up-to-date version of Vagrant!
使用するVagrant Boxのバージョン。
$ vagrant box list | grep ubuntu2204 generic/ubuntu2204 (libvirt, 4.1.2)
仮想マシンの起動と初期状態
まずはvagrant init
をしてから
$ vagrant init generic/ubuntu2204
起動、SSHログイン。
$ vagrant up $ vagrant ssh
パッケージの最新化だけしておきます。
$ sudo apt update $ sudo apt upgrade
$ uname -srvmpio Linux 5.15.0-43-generic #46-Ubuntu SMP Tue Jul 12 10:30:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.1 LTS Release: 22.04 Codename: jammy $ cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.1 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.1 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy
最初の状態。
$ date Tue Aug 2 01:04:59 PM UTC 2022 $ ll total 36 drwxr-x--- 4 vagrant vagrant 4096 Aug 2 13:00 ./ drwxr-xr-x 3 root root 4096 Jul 27 22:16 ../ -rw------- 1 vagrant vagrant 85 Aug 2 13:00 .bash_history -rw-r--r-- 1 vagrant vagrant 220 Jan 6 2022 .bash_logout -rw-r--r-- 1 vagrant vagrant 3775 Jul 27 22:24 .bashrc drwxr-xr-x 2 vagrant vagrant 4096 Jul 27 22:24 .cache/ -rw-r--r-- 1 vagrant vagrant 807 Jan 6 2022 .profile drwx------ 2 vagrant vagrant 4096 Aug 2 12:54 .ssh/ -rw-r--r-- 1 vagrant vagrant 13 Jul 27 22:24 .vimrc
ロケール。
$ env | grep LANG LANG=en_US.UTF-8 $ locale LANG=en_US.UTF-8 LANGUAGE= 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= $ localectl System Locale: LANG=en_US.UTF-8 VC Keymap: n/a X11 Layout: us X11 Model: pc105
使えるロケールの一覧。
$ locale -a C C.utf8 en_US.utf8 POSIX
タイムゾーンの設定。
$ cat /etc/timezone UTC $ timedatectl Local time: Tue 2022-08-02 13:06:50 UTC Universal time: Tue 2022-08-02 13:06:50 UTC RTC time: Tue 2022-08-02 13:06:50 Time zone: UTC (UTC, +0000) System clock synchronized: yes NTP service: active RTC in local TZ: no
Asia/Tokyo
タイムゾーンはインストールされていました。
$ timedatectl list-timezones | grep Asia/Tokyo Asia/Tokyo
manページの状態。
$ man grep GREP(1) User Commands GREP(1) NAME grep, egrep, fgrep, rgrep - print lines that match patterns SYNOPSIS grep [OPTION...] PATTERNS [FILE...] grep [OPTION...] -e PATTERNS ... [FILE...] grep [OPTION...] -f PATTERN_FILE ... [FILE...] DESCRIPTION grep searches for PATTERNS in each FILE. PATTERNS is one or more patterns separated by newline characters, and grep prints each line that matches a pattern. Typically PATTERNS should be quoted when grep is used in a shell command. A FILE of “-” stands for standard input. If no FILE is given, recursive searches examine the working directory, and nonrecursive searches read standard input. In addition, the variant programs egrep, fgrep and rgrep are the same as grep -E, grep -F, and grep -r, respectively. These variants are deprecated, but are provided for backward compatibility. OPTIONS Generic Program Information --help Output a usage message and exit. 〜省略〜
apt show
を見た時の状態。
$ apt show grep Package: grep Version: 3.7-1build1 Priority: required Essential: yes Section: utils Origin: Ubuntu Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> Original-Maintainer: Anibal Monsalve Salazar <anibal@debian.org> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 508 kB Provides: rgrep Pre-Depends: libc6 (>= 2.34), libpcre3 Depends: dpkg (>= 1.15.4) | install-info Suggests: libpcre3 (>= 7.7) Conflicts: rgrep Homepage: https://www.gnu.org/software/grep/ Task: minimal Download-Size: 156 kB APT-Manual-Installed: yes APT-Sources: https://mirrors.edge.kernel.org/ubuntu jammy/main amd64 Packages Description: GNU grep, egrep and fgrep 'grep' is a utility to search for text in files; it can be used from the command line or in scripts. Even if you don't want to use it, other packages on your system probably will. . The GNU family of grep utilities may be the "fastest grep in the west". GNU grep is based on a fast lazy-state deterministic matcher (about twice as fast as stock Unix egrep) hybridized with a Boyer-Moore-Gosper search for a fixed string that eliminates impossible text from being considered by the full regexp matcher without necessarily having to look at every character. The result is typically many times faster than Unix grep or egrep. (Regular expressions containing backreferencing will run more slowly, however.)
日本語化
では、日本語化していきます。
日本語ロケールの生成。
$ sudo locale-gen ja_JP.UTF-8 ### または $ sudo apt install language-pack-ja
locale
の一覧に、ja_JP.UTF-8
が追加されました。
$ locale -a C C.utf8 en_US.utf8 ja_JP.utf8 POSIX
LANG
およびLANGUAGE
環境変数の設定。
$ export LANG=ja_JP.UTF-8 $ export LANGUAGE=ja_JP:
コマンドの結果が日本語になりました。
$ date 2022年 8月 2日 火曜日 13:12:04 UTC vagrant@ubuntu2204:~$ ll total 40 drwxr-x--- 4 vagrant vagrant 4096 8月 2 13:07 ./ drwxr-xr-x 3 root root 4096 7月 27 22:16 ../ -rw------- 1 vagrant vagrant 85 8月 2 13:00 .bash_history -rw-r--r-- 1 vagrant vagrant 220 1月 6 2022 .bash_logout -rw-r--r-- 1 vagrant vagrant 3775 7月 27 22:24 .bashrc drwxr-xr-x 2 vagrant vagrant 4096 7月 27 22:24 .cache/ -rw------- 1 vagrant vagrant 20 8月 2 13:07 .lesshst -rw-r--r-- 1 vagrant vagrant 807 1月 6 2022 .profile drwx------ 2 vagrant vagrant 4096 8月 2 12:54 .ssh/ -rw-r--r-- 1 vagrant vagrant 13 7月 27 22:24 .vimrc
システム全体の設定を変える場合。
$ sudo update-locale LANG=ja_JP.UTF-8 LANGUAGE=ja_JP: ### または $ sudo localectl set-locale LANG=ja_JP.UTF-8 LANGUAGE=ja_JP:
シェルに再ログイン後、日本語化されます。
$ env | grep LANG LANGUAGE=ja_JP: LANG=ja_JP.UTF-8 $ localectl System Locale: LANG=ja_JP.UTF-8 LANGUAGE=ja_JP: VC Keymap: n/a X11 Layout: us X11 Model: pc105 $ locale LANG=ja_JP.UTF-8 LANGUAGE=ja_JP: LC_CTYPE="ja_JP.UTF-8" LC_NUMERIC="ja_JP.UTF-8" LC_TIME="ja_JP.UTF-8" LC_COLLATE="ja_JP.UTF-8" LC_MONETARY="ja_JP.UTF-8" LC_MESSAGES="ja_JP.UTF-8" LC_PAPER="ja_JP.UTF-8" LC_NAME="ja_JP.UTF-8" LC_ADDRESS="ja_JP.UTF-8" LC_TELEPHONE="ja_JP.UTF-8" LC_MEASUREMENT="ja_JP.UTF-8" LC_IDENTIFICATION="ja_JP.UTF-8" LC_ALL=
タイムゾーンの変更。
$ sudo timedatectl set-timezone Asia/Tokyo
確認。
$ cat /etc/timezone Asia/Tokyo $ timedatectl Local time: 火 2022-08-02 22:15:13 JST Universal time: 火 2022-08-02 13:15:13 UTC RTC time: 火 2022-08-02 13:15:13 Time zone: Asia/Tokyo (JST, +0900) System clock synchronized: yes NTP service: active RTC in local TZ: no
date
の結果も変わりました。
$ date 2022年 8月 2日 火曜日 22:15:28 JST
日本語manページのインストール。
$ sudo apt install manpages-ja manpages-ja-dev
manページが日本語化されました。
$ man grep GREP(1) General Commands Manual GREP(1) 名前 grep, egrep, fgrep - パターンにマッチする行を表示する 書式 grep [OPTIONS] PATTERN [FILE...] grep [OPTIONS] [-e PATTERN | -f FILE] [FILE...] 説明 grep は FILE で名前を指定されたファイルを検索して、与えられた PATTERN にマッチする部分を含む行を探します。 ファイルが指定されていない場合や、 ファイル名の代わ りに 1 個のマイナス記号 “-” が指定されている場合は、 grep は標準入力から検索します。 デフォルトでは、 grep はマッチした行を表示します。 さらに、兄弟プログラム egrep と fgrep は、それぞれ grep -E と grep -F と同じです。 これらの兄弟プログラムは非推奨ですが、後方互換性のために用意されています。 オプション プログラムについての一般情報 --help 使用法を出力して終了します。 〜省略〜
apt
での表示結果の日本語化。
$ sudo LANG=ja_JP.UTF-8 apt update
または、以下のファイルを作成して
/etc/apt/apt.conf.d/99translations
Acquire::Language "ja_JP";
apt update
。
$ sudo apt update
日本語化されました。
$ apt show grep Package: grep Version: 3.7-1build1 Priority: required Essential: yes Section: utils Origin: Ubuntu Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> Original-Maintainer: Anibal Monsalve Salazar <anibal@debian.org> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 508 kB Provides: rgrep Pre-Depends: libc6 (>= 2.34), libpcre3 Depends: dpkg (>= 1.15.4) | install-info Suggests: libpcre3 (>= 7.7) Conflicts: rgrep Homepage: https://www.gnu.org/software/grep/ Task: minimal Download-Size: 156 kB APT-Manual-Installed: yes APT-Sources: https://mirrors.edge.kernel.org/ubuntu jammy/main amd64 Packages Description: GNU grep, egrep, fgrep 'grep' はファイル内の文字列を検索するユーティリティです。コマンドラインか ら、またスクリプトから使用できます。あなたが使用しないとしても、おそらくあ なたのシステムにある他のパッケージが使用するでしょう。 . grep ユーティリティの GNU ファミリは "西洋最速の grep" かもしれません。GNU grep は、高速な遅延状態決定性照合器 (元祖 Unix の egrep より約 2 倍速い) を 元に固定長文字列に対して Boyer-Moore-Gosper 検索を併用し、一致するはずのな い文字列を完全正規表現照合器で除いており、不必要なすべての文字の探索はしな いようになっています。このため、一般には Unix の grep や egrep より数倍高速 です (しかし後方参照を含む正規表現では他より遅くなるでしょう)。
apt update
での日本語情報取得結果。
$ ll /var/lib/apt/lists/*-ja -rw-r--r-- 1 root root 1820339 4月 22 02:16 /var/lib/apt/lists/mirrors.edge.kernel.org_ubuntu_dists_jammy_main_i18n_Translation-ja -rw-r--r-- 1 root root 23071 4月 14 06:31 /var/lib/apt/lists/mirrors.edge.kernel.org_ubuntu_dists_jammy_multiverse_i18n_Translation-ja -rw-r--r-- 1 root root 9141549 4月 22 02:16 /var/lib/apt/lists/mirrors.edge.kernel.org_ubuntu_dists_jammy_universe_i18n_Translation-ja
まとめ
Ubuntu Linux 22.04 LTSを日本語化してみました。
Ubuntu Linux 20.04 LTSと同じ手順で日本語化できましたが、こうやってやり直してみるといろいろ忘れていることがあるので、良い復習の
機会になりますね。