
Ich habe WSL 2 auf meinem Windows 10 installiert. Ich habe ein Debian-System. Alles funktioniert einwandfrei.
Ich möchte WSL von einem PowerShell-Terminal aus starten, also gebe ich den Befehl ein wsl
. Ich erhalte die Fehlermeldung:
PS C:\Users\MyUser> wsl
wsl : The term 'wsl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ wsl
+ ~~~
+ CategoryInfo : ObjectNotFound: (wsl:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Warum das?
Aktualisieren Merkwürdigerweise bekomme ich eine negative Antwort, wenn ich versuche, den Befehl abzurufen:
PS C:\WINDOWS\system32> Get-Command wsl -All
Get-Command : The term 'wsl' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-Command wsl -All
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (wsl:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
Dennoch wsl.exe
befindet sich die ausführbare Datei dort C:\Windows\Syste32
, wo sie sein sollte ...
Wenn ich einen Alias festlege mit:
Set-Alias -Name wsl -Value C:\Windows\system32\wsl.exe
beim Ausführen ändert sich nichts an der Ausgabe wsl
(ich erhalte denselben Fehler).
Windows-Besonderheiten:
- Edition Windows 10 Pro
- Version 2004
- Betriebssystem-Build 19041.572
PS C:\WINDOWS\system32> Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
FeatureName : Microsoft-Windows-Subsystem-Linux
DisplayName : Windows Subsystem for Linux
Description : Provides services and environments for running native user-mode Linux shells and tools on Windows.
RestartRequired : Possible
State : Enabled
CustomProperties :
ServerComponent\Description : Provides services and environments for running native user-mode Linux shells and
tools on Windows.
ServerComponent\DisplayName : Windows Subsystem for Linux
ServerComponent\Id : 1033
ServerComponent\Type : Feature
ServerComponent\UniqueName : Microsoft-Windows-Subsystem-Linux
ServerComponent\Deploys\Update\Name : Microsoft-Windows-Subsystem-Linux
Antwort1
Da der Befehl
wslconfig.exe /l
gab als Antwort
Windows Subsystem for Linux Distributions:
docker-desktop-data
docker-desktop
Debian
Mir fiel auf, dass der Standard nicht gesetzt war. Daher habe ich einfach den Standard gesetzt:
wslconfig.exe /setdefault "Debian"
Jetzt wslconfig.exe /l
bekomme ich:
Windows Subsystem for Linux Distributions:
Debian (Default)
docker-desktop-data
docker-desktop
und ich kann die WSL 2-Standarddistribution mit starten wsl
.
Antwort2
Dies ist eigentlich keine Frage zum Powershell-Code, sondern eine Frage vom Typ „Wie richte ich WSL unter Windows 10 und einer Linux-Distribution in einer virtuellen Maschine ein und verwende es?“
WSL ist ein Dienst...
... ermöglicht die Ausführung von Linux-Distributionen unter Windows 10. Es handelt sich nicht um eine App/einen Befehl, der von PowerShell ausgeführt wird. Dieser Fehler ist also ziemlich spezifisch. Ihre Distribution muss ausgeführt werden!
Haben Sie die in den Videos gezeigten erforderlichen Schritte überprüft und genutzt?
- WSL 2: Erste Schritte
- So installieren und aktivieren Sie WSL in Windows 10 (+ Zugriff auf Dateien)
- So installieren Sie WSL 2 unter Windows 10 mit Powershell
...um WSL zu konfigurieren...
(Get-CimInstance -ClassName CIM_OperatingSystem).Version
# Results
<#
10.0.19041
#>
$PSVersionTable
# Results
<#
Name Value
---- -----
PSVersion 5.1.19041.546
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.19041.546}
BuildVersion 10.0.19041.546
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
#>
# Results
<#
Get-Command -Name wsl.exe
CommandType Name Version Source
----------- ---- ------- ------
Application wsl.exe 10.0.19... C:\WINDOWS\system32\wsl.exe
#>
Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
# Results
<#
FeatureName : Microsoft-Windows-Subsystem-Linux
DisplayName : Windows Subsystem for Linux
Description : Provides services and environments for running native user-mode Linux shells and tools on Windows.
RestartRequired : Possible
State : Enabled
CustomProperties :
ServerComponent\Description : Provides services and environments for running native user-mode Linux shells and tools on
Windows.
ServerComponent\DisplayName : Windows Subsystem for Linux
ServerComponent\Id : 1033
ServerComponent\Type : Feature
ServerComponent\UniqueName : Microsoft-Windows-Subsystem-Linux
ServerComponent\Deploys\Update\Name : Microsoft-Windows-Subsystem-Linux
#>
… und Ihre Distribution ist für die Verwendung dieser Linux-Distribution konfiguriert.
wsl --list --verbose
Windows Subsystem for Linux has no installed distributions.
Distributions can be installed by visiting the Microsoft Store:
https://aka.ms/wslstore