# How to install kali-wsl
> Author: Junner
> Date: 2024/09/24
## Commands
1. Open Command Prompt or PowerShell as an administrator. <small><small>[[1]](https://www.kali.org/docs/wsl/wsl-preparations/)</small></small>
2. Run the following commands. <small><small>[[1]](https://www.kali.org/docs/wsl/wsl-preparations/)</small></small>
```bash=
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all
```
3. Reboot your computer to apply the changes.
4. Set the wsl version. <small><small>[[1]](https://www.kali.org/docs/wsl/wsl-preparations/)</small></small>
You can choose `wsl1` or `wsl2` for your destiny version.
>Windows Subsystem for Linux (WSL) has two different versions, “WSL 1” and “WSL 2”. WSL 2 is the preferred and default option when installing WSL. This is because WSL 2 uses the actual Linux kernel inside a Hyper-V virtual machine (managed by WSL). WSL 1 uses a “translation layer” which is similar to WINE.
Run:
```bash=
wsl --set-default-version <version>
```
For example, to set it to `wsl2`, you would enter
```bash=
wsl --set-default-version 2
```
On some computer, `wsl2` doesn't run well. And you may set the version to 1.
```bash=
wsl --set-default-version 1
```
5. Windows sets Ubuntu as the default distro. To list other distro, run the command below and look for the name containing `kali`. <small><small>[[2]](https://learn.microsoft.com/zh-tw/windows/wsl/install)</small></small>
```bash=
wsl -l -o
```

6. Installation <small><small>[[2]](https://learn.microsoft.com/zh-tw/windows/wsl/install)</small></small>
```bash=
wsl --install -d kali-linux
```
## References
* [Kali WSL:[1]](https://www.kali.org/docs/wsl/wsl-preparations/)
* [如何使用 WSL 在 Windows 上安裝 Linux:[2]](https://learn.microsoft.com/zh-tw/windows/wsl/install)