### 1. Version (wsl --version (or) wsl -v )
```sh
# wsl --version (or) wsl -v will provide version of wsl , version of distributions or version of windows
PS> wsl --version
/*Result */
WSL version: 1.2.5.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.3208
```
### 2. List (wsl --list (or) wsl -l [Options]
Lists distributions.
Options:
--all
List all distributions, including distributions that are
currently being installed or uninstalled.
--running
List only distributions that are currently running.
--quiet, -q
Only show distribution names.
--verbose, -v
Show detailed information about all distributions.
--online, -o
Displays a list of available distributions for install with 'wsl.exe --install'.
```sh
❯ wsl --list
/*Result */
Windows Subsystem for Linux Distributions:
Ubuntu (Default)
SLES-12
❯ wsl -l
/*Result */
Windows Subsystem for Linux Distributions:
Ubuntu (Default)
SLES-12
❯ wsl -l --running
/*Result */
There are no running distributions.
❯ wsl -l -q
/*Result */
Ubuntu
SLES-12
❯ wsl -l -v
/*Result */
NAME STATE VERSION
* Ubuntu Running 1
SLES-12 Stopped 1
❯ wsl -l --online
/*Result */
The following is a list of valid distributions that can be installed.
Install using 'wsl.exe --install '.
NAME FRIENDLY NAME
Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
Ubuntu-18.04 Ubuntu 18.04 LTS
Ubuntu-20.04 Ubuntu 20.04 LTS
Ubuntu-22.04 Ubuntu 22.04 LTS
OracleLinux_7_9 Oracle Linux 7.9
OracleLinux_8_7 Oracle Linux 8.7
OracleLinux_9_1 Oracle Linux 9.1
openSUSE-Leap-15.5 openSUSE Leap 15.5
SUSE-Linux-Enterprise-Server-15-SP4 SUSE Linux Enterprise Server 15 SP4
SUSE-Linux-Enterprise-15-SP5 SUSE Linux Enterprise 15 SP5
openSUSE-Tumbleweed openSUSE Tumbleweed
```
### 3. Run the specified distribution. (wsl -d \ wsl --distribution)
```sh
# list all distributions with status
> wsl -l -v
/*Result */
NAME STATE VERSION
* Ubuntu Stopped 1
SLES-12 Stopped 1
> wsl -d SLES-12
/*Result */
/mnt/c/Users/user>
❯ wsl -l -v
/*Result */
NAME STATE VERSION
* Ubuntu Stopped 1
SLES-12 Running 1
> /mnt/c/Users/user> exit
/*Result */
logout
```
### 4. terminate the specified distribution. (wsl -d \ wsl --distribution)
```sh
#wsl --terminate, -t
❯ wsl -t SLES-12
/*Result */
The operation completed successfully.
```
### 5. Update \ upgrate wsl package
```sh
# update wsl package using internet instead of microsoft store
> wsl --update --web-download
/*Result */
Checking for updates.
The most recent version of Windows Subsystem for Linux is already installed.
```
### 6. Set WSL version 2
```sh
> wsl --set-default-version 2
/*Result */
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
The operation completed successfully.
```
### 7. Changes the version of the specified distribution.
```sh
> wsl --set-version SLES-12 2
/*Result */
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion in progress, this may take a few minutes.
The operation completed successfully.
> wsl -l -v
/*Result */
NAME STATE VERSION
* Ubuntu Stopped 1
SLES-12 Stopped 2
> wsl --set-version ubuntu 2
/*Result */
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion in progress, this may take a few minutes....
The operation completed successfully.
> wsl -l -v
/*Result */
NAME STATE VERSION
* Ubuntu Stopped 2
SLES-12 Stopped 2
```
### 8. unregister the specified distribution
```sh
#Unregisters the distribution and deletes the root filesystem.
#wsl --unregister
> wsl --unregister SLES-12
```
### 9. WSL SEr
```sh
> wsl --status
/*Result */
Default Distribution: Ubuntu
Default Version: 2
```
Azure Cloud Solution Architect, Full-Stack Development in .Net Eco system, Senior Manager at Capgemini
Saturday, July 29, 2023
WSL CLI commands
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment