メインメニュー
XAMPP アレンジ
IED
WSL2
-
道具箱
リポジトリ編
フレームワーク編
公開ソフトウェア
メタ
リンク
- PHP ライブラリ
- PHP 言語
wsl2:command目次
文書の過去の版を表示しています。
編集中WSL2 インストール
— y2sunlight 2020-12-07
関連記事
- WSL2 コマンドリファレンス
リンク
- Command Reference for Windows Subsystem for Linux — Microsoftドキュメント
本章は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
List all distributions, including distributions that are currently being installed or uninstalled.--running
List only distributions that are currently running.
--set-default <Distro>
,-s <Distro>
Sets the distribution as the default.
--terminate <Distro>
,-t <Distro>
Terminates the specified distribution.
--unregister <Distro>
Un-register the distribution.
--help
Display usage information.
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 runslxrun /install
~
bash ~
launches the bash shell into the user's home directory. Similar to runningcd ~
.
-c “<command>”
Runs the command, prints the output and exits back to the Windows command prompt.
Example:bash -c “ls”
wsl2/command.1607318173.txt.gz · 最終更新: 2020/12/07 14:16 by y2sunlight
コメント
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. 토토사이트