DEV Community

Borikatsu
Borikatsu

Posted on • Edited on

wsl2 の設定備忘録

個人用備忘録。OS は Ubuntu 前提です


目次


root 以外のユーザをデフォルト起動ユーザにしたい

基本設定

VSCode とかで wsl に接続した際にデフォルト起動ユーザを変更する方法。
公式の方法

Ubuntu にログインして conf の設定を変更するだけ
※hoge の部分はユーザ名

$ sudo vi /etc/wsl.conf
[user]
default=hoge
Enter fullscreen mode Exit fullscreen mode

Windows Terminal での設定

[設定] → [Ubuntu] → [コマンドライン]
を開いて起動コマンドを変更する。
※hoge の部分はユーザ名

# デフォルト
C:\WINDOWS\system32\wsl.exe -d Ubuntu

# 変更後
C:\WINDOWS\system32\wsl.exe -d Ubuntu --user hoge
Enter fullscreen mode Exit fullscreen mode

GUI の有効化

Windows 10 から利用できるようになった Windows Subsystem for Linux GUI を利用。

最新版の wsl でなければ更新。

# 管理者権限が必要
> wsl --update

# バージョン確認
> wsl --version
WSL バージョン: 1.2.5.0
カーネル バージョン: 5.15.90.1
WSLg バージョン: 1.0.51 # GUI機能が利用可能
MSRDC バージョン: 1.2.3770
Direct3D バージョン: 1.608.2-61064218
DXCore バージョン: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows バージョン: 10.0.22621.2428
Enter fullscreen mode Exit fullscreen mode

X11 アプリケーションをインストールして GUI が wsl から利用できるか確認。

$ sudo apt update
$ sudo apt install -y x11-apps

電卓が起動すればWSLgを利用できる状態
$ xcalc
Enter fullscreen mode Exit fullscreen mode

Chromiumのインストール

sudo apt install -y libgtk2.0-0 libgtk-3-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb libgbm-dev fonts-ipafont
Enter fullscreen mode Exit fullscreen mode

sshの鍵設定

# keychain インストール
$ sudo apt-get install keychain

$ 起動設定
$ vi ~/.bashrc
/usr/bin/keychain -q --nogui $HOME/.ssh/id_rsa
source $HOME/.keychain/$HOST-sh
Enter fullscreen mode Exit fullscreen mode

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay