Logo

dev-resources.site

for different kinds of informations.

Install Ubuntu on WSL 2

Published at
9/30/2024
Categories
wsl
wsl2
powershell
Author
prastha
Categories
3 categories in total
wsl
open
wsl2
open
powershell
open
Author
7 person written this
prastha
open
Install Ubuntu on WSL 2

WSL2 (Windows Subsystem for Linux 2) is a compatibility layer allowing users to run a full Linux kernel and native Linux applications on Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11.

Install WSL command

  1. Run PowerShell or Command Prompt as administrator

  2. Run the “wsl —install” command to install. This will install default version of WSL.

    >wsl --install
    
  3. Restart PC

  4. Check wsl Installation

    >wsl --version
    WSL version: 2.2.4.0
    ....
    
  5. Check installed Ubuntu with command “wsl --list --verbose” (or wsl -l -v).

    >wsl -l -v
      NAME                   STATE           VERSION
      Ubuntu                 Stopped         2
    
  6. Enter Ubuntu Distribution.

    >wsl -d Ubuntu
    root@DESKTOP-FMBB4IH:/mnt/c/WINDOWS/system32#
    
  7. Check the installed Ubuntu version.

    root@DESKTOP-FMBB4IH:/mnt/c/WINDOWS/system32#lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 22.04.3 LTS
    Release:        22.04
    Codename:       jammy
    

Change the installed default Linux distribution

  1. To check the version of default Linux distribution

    Check the above “Install WSL command” procedure numbers 5, 6, and 7.

  2. Check available distribution name using command wsl --list --online(wsl -l -o).

    >wsl -l -o
    Install using 'wsl.exe --install <Distro>'.
    
    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
    Ubuntu-24.04                    Ubuntu 24.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.6              openSUSE Leap 15.6
    SUSE-Linux-Enterprise-15-SP5    SUSE Linux Enterprise 15 SP5
    SUSE-Linux-Enterprise-15-SP6    SUSE Linux Enterprise 15 SP6
    openSUSE-Tumbleweed             openSUSE Tumbleweed
    
  3. To change the installed default Linux distribution to Ubuntu-22.04.

    Syntax: wsl --install -d <Distribution Name>

    >wsl --install -d Ubuntu-24.04
    Installing: Ubuntu 24.04 LTS
    Ubuntu 24.04 LTS has been installed.
    Launching Ubuntu 24.04 LTS...
    Installing, this may take a few minutes...
    Please create a default UNIX user account. The username does not need to match your Windows username.
    For more information visit: https://aka.ms/wslusers
    Enter new UNIX username:
    

    Enter username and password 2 times when prompted.

  4. Changed distribution is ready to use.

    Check the above “Install WSL command” procedure numbers 5, 6, and 7.

  5. To enter the distribution

    Just after installation or changing the distribution, the distribution is opened. To open the distribution from next time, enter the following command:

    Syntax: wsl -d <Distribution Name>

    >wsl -d Ubuntu-24.04
    
  6. To exit the distribution

    >exit
    
  7. To uninstall the distribution

    Syntax: wsl —unregister <Distribution Name>

    >wsl --unregister Ubuntu-24.04
    

Reference

  1. Windows Subsystem for Linux Documentation
powershell Article's
30 articles in total
Favicon
Windows 上 VSCode 的 C/C++ 延伸模組處理編碼的問題
Favicon
PowerShell 的文字編碼
Favicon
笔记3
Favicon
TryHackMe | Windows PowerShell | RSCyberTech
Favicon
Configuring Hyper-V Global Default Directories
Favicon
How I Set Up an Awesome PowerShell Environment for Script Development
Favicon
Azure Function App (Flex Consumption) PowerShell Modules solution
Favicon
File Comparison Made Easy: Detecting New and Changed Files with PowerShell
Favicon
10 Best Practices of PowerShell Code Signing for Signing Your Script
Favicon
PowerShell Script Collection: Automation and Solutions for Everyday Tasks
Favicon
Video: List All Available Windows Features on Windows 11 using CMD & PowerShell
Favicon
Set up Azure Network Security Perimeter with PowerShell
Favicon
Automating Azure Project Setup with PowerShell and GitHub Actions
Favicon
Azure Function App (Flex Consumption) in private VNET via IaC
Favicon
Using PowerShell to Create Service Principals for RBAC
Favicon
Two ways to use Pester to Mock objects with strongly typed parameters
Favicon
PowerShell Automation: Execute Batch GitHub CLI Commands
Favicon
❓ Do you allow wrong input to enter your function?
Favicon
Introducing PowerShell Utility Scripts
Favicon
Cisco DHCP Pool conversion to Windows Server DHCP
Favicon
PowerShell | Script output garbled Chinese characters
Favicon
Rename Multiple Files in Sequence with Just One Click Using PowerShell in Windows! 🚀
Favicon
Redirect Out-File to TestDrive: in your PowerShell Pester test scripts with this one weird trick
Favicon
Using PowerShell for day to day stuff
Favicon
Automating SharePoint Embedded: Using PowerShell to Call Graph API Endpoints
Favicon
Install Ubuntu on WSL 2
Favicon
How to Install WSL from PowerShell on Windows 10 and 11
Favicon
How to Run PowerShell Script in Jenkins Pipeline
Favicon
Identify Which Files are Large.
Favicon
Quick guide to setting up an shortcut/alias in windows

Featured ones: