Windows:- WSL – Managing distributions in Windows Subsystem for Linux – Targeting Specific Distribution

Background

Obviously, my working OS is MS Windows.

But, I have very brief moments with Linux.

Once every couple of moments or so.

 

Managing Distributions in Windows Subsystem for Linux

Outline

Management-wise, here are some of what we can do with WSL:-

  1. Export and Import
    • Export the distribution to a tar file
    • Import specified tar file as a new distribution
  2. List Distributions
    • List all distributions
    • List running distributions
  3. Set default distribution
  4. Target Specific distribution
  5. Status Inquiry
  6. Terminate a running distribution
  7. Unregister a distribution and delete the root file system

 

Objective

In this post, we will target a specific distribution.

 

Tasks

List Distributions

List all distributions

Syntax

wsl --list

 

Sample

wsl --list -all

Output
Output – Image

Output – Textual

>wsl --list --all
Windows Subsystem for Linux Distributions:
CentOS8-stream (Default)
Ubuntu

 

Explanation
  1. We have two Linux distributions installed:-
    • CentOS8-Stream
    • Ubuntu
  2. Default Distribution
    • The default distribution is CentOS8-Stream

Target Specific Distribution

If we want to target a different distribution other than our default.

For us our default is CentOS8-Stream.

If we are to want to work on Ubuntu, we will invoke wsl and pass along Ubuntu as our distribution.

Syntax

wsl --distribution [distribution]

 

Sample

Let us request Ubuntu.


wsl --distribution ubuntu

Output
Output – Image

Output – Textual


>wsl --distribution ubuntu

dadeniji@lab:/mnt/c$

 

Explanation

 

OS Version Inquiry

Please check the OS Version.

File – /etc/lsb-release

Let us read the contents of the /etc/lsb-release file.

Syntax

cat /etc/lsb-release

 

Sample

cat /etc/lsb-release

Output
Output – Image

Output – Textual

>cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04 LTS"
>

 

Explanation
  1. Distribution ID:- Ubuntu
  2. Distribution Release:- 20.04
  3. Distribution Codename:- Focal
  4. Distribution Description:- Ubuntu 20.04 LTS

 

References

  1. Microsoft
    • WSL
      • Basic Commands
        Link

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s