0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WindowsでLinuxコマンドを実行する

Posted at

WSL2をセットアップしたときの自分用メモ


インストール

  • Ubuntuをインストール
PS C:\Windows\system32> wsl --list --online
インストールできる有効なディストリビューションの一覧を次に示します。
既定の分布は ' * ' で表されます。
 'wsl --install -d <Distro>'を使用してインストールします。

  NAME            FRIENDLY NAME
* Ubuntu          Ubuntu
  Debian          Debian GNU/Linux
  kali-linux      Kali Linux Rolling
  openSUSE-42     openSUSE Leap 42
  SLES-12         SUSE Linux Enterprise Server v12
  Ubuntu-16.04    Ubuntu 16.04 LTS
  Ubuntu-18.04    Ubuntu 18.04 LTS
  Ubuntu-20.04    Ubuntu 20.04 LTS
PS C:\Windows\system32> wsl --install -d Ubuntu
インストール中: 仮想マシン プラットフォーム
仮想マシン プラットフォーム はインストールされました。
インストール中: Linux  Windows サブシステム
Linux  Windows サブシステム はインストールされました。
ダウンロード中: WSL カーネル
インストール中: WSL カーネル
WSL カーネル はインストールされました。
ダウンロード中: Ubuntu
要求された操作は正常に終了しました。変更を有効にするには、システムを再起動する必要があります。
PS C:\Windows\system32>

Ubuntuを起動するがエラー

  • 仮想マシン内(WIndows)で仮想環境(Ubuntu)を起動していることが原因
    image.png

解決策

  • 物理マシンにて「インテル® プロセッサ 識別 ユーティリティ」をインストール
    VT-x(最下部の項目)が有効であることを確認
    image.png

  • VMware Workstation 16 Playerにて「Intel VT-x/EPT または AMD-V/RVI を仮想化」を有効化
    image.png

設定

  • ユーザーとパスワードを設定 ※ここでは「user001」
    image.png

  • パッケージ更新

sudo apt update
sudo apt -y upgrade
  • 日本語化
sudo apt -y install language-pack-ja
locale
sudo update-locale LANG=ja_JP.UTF8

image.png

  • 「exit」して再度起動して反映されていることを確認
    image.png

ファイル移動

  • エクスプローラーから「\wsl$」を開く
  • ドラッグアンドドロップでファイルを移動
    image.png
    image.png

感想

  • 今までPowershellで似たようなコマンドを探したり、Git Bashを使っていた
    • バッククオートが使えなかったりと不便だった
  • Windowsでも開発しやすくなった
  • Cloud9を使うほどでもないときやローカル環境必須の場合に使っていきたい
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?