LoginSignup
12
18

More than 1 year has passed since last update.

WSL2でUbuntuのGUIを起動(メモ)

Posted at

WSL2のインストール

  • 前提:Windows10 version 2004以降であること
  • コマンドプロンプトを管理者権限で開く
  • 次のコマンドを入力(デフォルトでUbuntuがインストールされる)
wsl --install
  • 初回起動時にユーザー名とパスワードを設定する

Ubuntuデスクトップ環境の構築

Ubuntuのアップデート

  • ターミナルで以下のコマンドを入力
$ sudo apt-get update
$ sudo apt-get upgrade 

Ubuntuデスクトップ環境のインストール

$ sudo apt-get install libgl1-mesa-dev xorg-dev xbitmaps x11-apps
$ sudo apt-get install ubuntu-desktop

Xサーバ環境の構築

VcXsrvのインストール

  • 公式サイトからインストーラをダウンロード
  • 設定はデフォルトのままでOK

VcXsrvの起動

  • XLaunchというアイコンから起動
  • 「One large window」を選択
  • 「Disable access control」にチェック
  • 「Windows セキュリティの重要な警告」が表示されたら、「パブリックネットワーク」にチェックを入れて、「アクセスを許可する」を押す

Ubuntuデスクトップの起動

$ export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0.0
$ sudo service x11-common start
$ sudo service dbus start
$ gnome-shell --x11 -r
  • これでデスクトップ画面が起動する

楽にUbuntuデスクトップを起動する方法(シェルスクリプト作成)

  • 前提:VcXsrvを起動しておく

準備編

  • Ubuntuで以下のコマンドを入力してviエディタ起動
$ vi start.sh
  • iを押してインサートモードにする
  • 以下のコマンドをコピーしてviエディタに貼り付け
$ export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0.0
$ sudo service x11-common start
$ sudo service dbus start
$ gnome-shell --x11 -r
  • escを押す→:wq→Enter
  • 元のターミナルに戻ったら以下のコマンドを入力
$ sudo bash start.sh
  • Ubuntuデスクトップが起動する

参考

Windows 10でLinuxを使う(WSL2)
WSLをつかって、Ubuntuのデスクトップ(GUI)をうごかしてみよう

12
18
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
12
18