LoginSignup
2
4

WSL2に新しくUbuntuを入れたときにやることメモ

Last updated at Posted at 2024-04-27

WSLに Ubuntu-24.04 が降ってきてますね!
毎回インストール後にやること忘れてるのでこの機会にメモ。

実施時環境

  • Windows 11 Home 23H3
  • WSL 2.1.5.0
  • Ubuntu 24.04 LTS

端末からビープ音が鳴りまくるのをやめさせる

デフォルトでタブ押す度にビィンビィン鳴りまくるのやや狂気を感じる。

echo 'set bell-style none' >> ~/.inputrc

設定後、端末への再ログインが必要。

よく使うけどデフォルトで居ない奴らをインストールする

sudo apt update
sudo apt install -y net-tools wget unzip jq

sudo なしの n で node, npm を管理する

n が好きです。

mkdir ~/.n
cat << EOS >> ~/.profile
export N_PREFIX=\$HOME/.n
export PATH=\$N_PREFIX/bin:\$PATH
EOS
source ~/.profile

sudo apt install -y npm
sudo npm install -g n
n stable

sudo npm uninstall -g n
sudo apt purge -y npm
sudo apt autoremove -y

source ~/.profile
npm install -g n

以上で apt が連れてきた npm と、apt が連れてきた npm が連れてきた n は追い出せたはず。

バージョン確認は

node -v
npm -v
n -V

Docker Engine のインストール

Docker Desktop は使わない派です。

sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

sudo service docker start

インストールコマンドは公式からの転記ですが、結構頻繁に変わってる印象があるのでちゃんと本家を読んだ方が良い。

毎回 sudo するのが嫌なので自分のアカウントを docker グループに追加しておく:

sudo gpasswd -a $(whoami) docker

設定後、端末への再ログインが必要。gpasswd の結果を反映させるには、結局再ログインが一番簡単だと思います。

バージョン確認は docker -v 、動作確認は docker run --rm hello-world

AWS CLI のインストール

aws

temp=$(mktemp -d)
pushd "${temp}"
wget "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"
unzip "awscli-exe-linux-x86_64.zip"
sudo ./aws/install
popd
rm -rf "${temp}"

バージョン確認は aws --version

sam

temp=$(mktemp -d)
pushd "${temp}"
wget "https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip"
unzip "aws-sam-cli-linux-x86_64.zip"
sudo ./install
popd
rm -rf "${temp}"

バージョン確認は sam --version

日本語対応

こちらの記事を参考にさせて頂いております:

sudo apt install -y language-pack-ja fonts-noto fcitx-mozc dbus-x11
sudo update-locale LANG=ja_JP.utf8

cat << EOS >> ~/.profile
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
export DefaultIMModule=fcitx
if [ $SHLVL = 1 ] ; then
  (fcitx-autostart > /dev/null 2>&1 &)
  xset -r 49  > /dev/null 2>&1
fi
EOS

設定後、端末への再ログインが必要。

再ログイン後 fcitx-configtool でGUIの設定ツールを起動してこんな感じの設定にすればOK:

image.png

2
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
2
4