Ground Sunlight

Windowsで作る - PHPプログラミングの開発環境

ユーザ用ツール

サイト用ツール


サイドバー

メインメニュー

XAMPP アレンジ

IED

WSL2

道具箱

リポジトリ編

フレームワーク編

公開ソフトウェア

メタ
リンク


このページへのアクセス
今日: 3 / 昨日: 2
総計: 2768

wsl2:command

文書の過去の版を表示しています。


編集中

WSL2 インストール

y2sunlight 2020-12-07

WSL2に戻る

関連記事

リンク

本章はMicrosoftドキュメントの邦訳に注釈を加えたものです。


WSL(Linux用のWindowsサブシステム)と対話する最良の方法は、wsl.exeコマンドを使用することです。

WSL2をデフォルトバージョンとして設定する

Powershellで次のコマンドを実行して、新しいLinuxディストリビューションをインストールするときにWSL2をデフォルトバージョンとして設定します。

wsl --set-default-version 2


ディストリビューション バージョンをWSL1またはWSL2に設定する

PowerShellコマンドラインを開いて次のコマンドを入力すると、インストールした各Linuxディストリビューションに割り当てられているWSLバージョンを確認できます。( Windowsビルド19041以降でのみ使用可能: wsl -l -v

wsl --list --verbose

実行例

PS C:\> wsl --list --verbose
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2

どちらかのバージョンのWSLにより戻されるディストリビューションを設定するには、以下を実行してください:

wsl --set-version <distribution name> <versionNumber>

<distribution name> はディストリビューションの実際の名前に置き換え、<versionNumber> は番号「1」または「2」に置き換えてください。上記と同じコマンドを実行し、「2」を「1」に置き換えることで、いつでもWSL1に戻すことができます。

さらに、WSL2をデフォルトのアーキテクチャにしたい場合は、次のコマンドを使用して行うことができます:

wsl --set-default-version 2

これにより、インストールされた新しいディストリビューションのバージョンがWSL2に設定されます。

wsl.exe

以下は、Windowsバージョン1903以降の wsl.exe を使用する場合のすべてのオプションを含むリストです。

Using: wsl [Argument] [Options...] [CommandLine]


Linuxコマンドを実行する

  • 引数なし
    コマンドラインが指定されていない場合、wsl.exe はデフォルトのシェルを起動します。
  • --exec <CommandLine>, -e <CommandLine>
    デフォルトのLinuxシェルを使用せずに、指定されたコマンドを実行します。
  • --
    残りのコマンドラインをそのまま渡します。

上記のコマンドは、次のオプションも受け入れます:

  • --distribution <Distro>, -d <Distro>
    指定されたディストリビューションを実行します。
  • --user <UserName>, -u <UserName>
    指定されたユーザーとして実行します。


WSLを管理する

  • --export <Distro> <FileName>
    ディストリビューションをtarファイルにエクスポートします。ファイル名は、標準出力の場合は - にすることができます。
  • --import <Distro> <InstallLocation> <FileName>
    指定されたtarファイルを新しいディストリビューションとしてインポートします。ファイル名は、標準入力の場合は - にすることができます。
  • --list [Options], -l [Options]
    ディストリビューションをリストします.
    Options:
    • --all
      現在インストールまたはアンインストールされているディストリビューションを含む、すべてのディストリビューションを一覧表示します。
    • --running
      現在実行中のディストリビューションのみを一覧表示します。
  • --set-default <Distro>, -s <Distro>
    デフォルトのディストリビューションを設定します。
  • --terminate <Distro>, -t <Distro>
    指定されたディストリビューションを終了します。
  • --unregister <Distro>
    ディストリビューションの登録を解除します。
  • --help 使い方を表示します。


Additional Commands

There are also historic commands to interact with the Windows Subsystem for Linux. Their functionality is encompassed within wsl.exe, but they are still available for use.


wslconfig.exe

This command lets you configure your WSL distribution. Below is a list of its options.

使用法

wslconfig [Argument] [Options...]

引数

  • /l [Options], /list [Options]
    Lists registered distributions.

Options:

  • /all
    Optionally list all distributions, including distributions that are currently being installed or uninstalled.
  • /running
    List only distributions that are currently running.
  • /s <Distro>, /setdefault <Distro>
    Sets the distribution as the default.
  • /t <Distro>, /terminate <Distro>
    Terminates the distribution.
  • /u <Distro>, /unregister <Distro>
    Un-registers the distribution.
  • /upgrade <Distro>
    Upgrades the distribution to the WslFs file system format.


bash.exe

This command is used to start a bash shell. Below are the options you can use with this command.

使用法:

bash [Options...]
  • No Option given
    Launches the Bash shell in the current directory. If the Bash shell is not installed automatically runs lxrun /install
  • ~
    bash ~ launches the bash shell into the user's home directory. Similar to running cd ~.
  • -c “<command>”
    Runs the command, prints the output and exits back to the Windows command prompt.
    Example: bash -c “ls”


コメント

test52.194.191.136, 2023/06/21 17:47

Friends are happy to see your posts. I've been to school and I'm looking at your blog posts when I'm in a bad mood. I feel good after reading the article. Do your best in the future. 토토사이트

コメントを入力. Wiki文法が有効です:
 
wsl2/command.1607322927.txt.gz · 最終更新: 2020/12/07 15:35 by y2sunlight