Manage WSL
This topic is: intermediate
I recommend you to first familiarize yourself with everything before.
Here's a list of the most common used commands to manage WSL. You must run these commands in Powershell.
View a list of commands
wsl --help
Install a distro
wsl --install <distro>
wsl --install kali-linux
View a list of distros installed in WSL
wsl --list
Set the default distribution to use
wsl --set-default <distro>
Run a specific distro
wsl --distribution <distro>
Run a distro in specific directory
wsl --cd <directory>
wsl --cd "/"
wsl --cd "~"
wsl --cd "C:\Users\Bob"
Finalize all running distros and close WSL
wsl --shutdown
Export a WSL distro (backup)
wsl --export <distro> <filename>
Where <distro>
is the name of the distribution you want to export, and <filename>
the address where the .tar
file will be exported.
wsl --export Ubuntu-20.04 UbuntuBackup.tar
You can create backups of your distros with this.
Import a WSL distro
wsl --import <distro> <install_location> <filename>
Where <distro>
is the name of the distribution (it can be anything), <install_location>
is the address where the filesystem will be installed, and <filename>
is the address where the exported .tar
file is located.
wsl --import MyUbuntu "C:\WSL\Ubuntu" UbuntuBackup.tar
Delete a WSL distro
wsl --unregister <distro>
wsl --unregister Ubuntu-20.04
THIS WILL REMOVE EVERYTHING INSIDE THAT DISTRO!
And it's not recoverable. Make sure to backup!
Last updated