Setup and Configure WSL(Windows Subsystem for Linux) & Run Kali Linux on WSL2

Setup and Configure WSL(Windows Subsystem for Linux) & Run Kali Linux on WSL2

December 17, 2021 9 min read 3 views 0 discussions
Table of Contents

    The Windows Subsystem for Linux (WSL) is a feature of the Windows operating system that enables you to run a Linux file system, along with Linux command-line tools and GUI apps, directly on Windows, alongside your traditional Windows desktop and apps.

    Microsoft Windows[Version 10.0.19044.1288]
    (c) Microsoft Corporation. All right reserved.

    C:\Users\mrdeveloper>wsl --help                                                                     
    Copyright (c) Microsoft Corporation. All rights reserved.
    Usage: wsl.exe [Argument] [Options...] [CommandLine] 
    Arguments for running Linux binaries: 
       If no command line is provided, wsl.exe launches the default shell.

       --exec, -e <CommandLine>
         Execute the specified command without using the default Linux shell.
       --
         Pass the remaining command line as is.

    Options:
        --distribution, -d <Distro>     
               Run the specified distribution. 
        --user, -u <UserName>
               Run as the specified user.

    Arguments for managing Windows Subsystem for Linux:     
        --help
           Display usage information.                                                                                                                                                                          
        --install [Options]  
           Install additional Windows Subsystem for Linux distribution.         For a list of valid distributions, use 'wsl --list --online'.

           Options: 
               --distribution, -d [Argument]      
                  Downloads and installs a distribution by name. 
               Arguments:                                                                                              
                  A valid distribution name (not case sensitive).                                                                                                                                                     
              Examples:  
                        wsl --install -d Ubuntu       
                        wsl --install --distribution Debian  

         --set-default-version <Version>
              Changes the default install version for new distributions. 
         --shutdown
              Immediately terminates all running distributions and the WSLlightweight utility virtual machine.
         --status                                                                                             
              Show the status of Windows Subsystem for Linux.
         --update [Options] 
              If no options are specified, the WSL 2 kernel will be updated to the latest version.
          Options:          --rollback       Revert to the previous version of the WSL 2 kernel.

     Arguments for managing distributions in Windows Subsystem for Linux:
     --export <Distro> <FileName>  
         Exports the distribution to a tar file. The filename can be - for standard output.  
     --import <Distro> <InstallLocation> <FileName> [Options] 
         Imports the specified tar file as a new distribution.    The filename can be - for standard input.
    Options:  
         --version <Version>
              Specifies the version to use for the new distribution.
        --list, -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 --install'.
     --set-default, -s <Distro>
           Sets the distribution as the default.
     --set-version <Distro> <Version> 
           Changes the version of the specified distribution. 
    --terminate, -t <Distro>
           Terminates the specified distribution.
    --unregister <Distro>
           Unregisters the distribution and deletes the root filesystem.     

    C:\Users\mrdeveloper>
    C:\users\mrdeveloper>wsl --set-default-version 2
    Microsoft Windows[Version 10.0.19044.1288]
    (c) Microsoft Corporation. All right reserved.

    C:\Users\mrdeveloper>wsl --list --online
    The following is a list of valid distributions that can be installed.
    Install using 'wsl --install -d <Distro>'.
            NAME            FRIENDLY NAME
            Ubuntu          Ubuntu                             
            Debian          Debian GNU/Linux                               
            kali-linux      Kali Linux Rolling                              
            openSUSE-42     openSUSE Leap 42                     
            SLES-12         SUSE Linux Enterprise Server v12                  
            Ubuntu-16.04    Ubuntu 16.04 LTS                        
            Ubuntu-18.04    Ubuntu 18.04 LTS                                 
            Ubuntu-20.04    Ubuntu 20.04 LTS            

    C:\Users\mrdeveloper>                                                                                                          
    C:\users\mrdeveloper>wsl --install -d kali-linux


    Install and Configure Kali Linux on the WSL service


    Step 1: Enable the Windows Subsystem for Linux:

    • Press Windows + S and then Type "Turn Windows Features on or off".
    • Turn on Windows Subsystem for Linux and also enable Virtualisation.

    Click OK and then restart the PC.

    Step 2: Check requirements for running WSL 2

    You must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11.

    Note:

    To check your Windows version and build number, select Windows logo key + R, type winver, select OK. You can update to the latest Windows version by selecting Start > Settings > **Windows Update **> Check for updates.

    If you're running an older build, or just prefer not to use the install command and would like step-by-step directions, see WSL manual installation steps for older versions.

    Step 3: Status of Windows Subsystem for Linux:

    Run Power Shell as an administrator and check whether WSL is installed or not.

    Step 4: Download the Linux Kernel Update Package

      Download the latest package: WSL2 Linux kernel update package for x64 machines

    Step 5: Set WSL 2 as your default version

    Open PowerShell and run this command to set WSL 2 as the default version when installing a new Linux distribution:

    Step 6: Download and Install the Linux distribution

    Download and install Linux Distribution using the below methods:

    Method 1: From Microsoft store by searching distribution name:


    Method 2: Check the available distribution by using this command:

    For Example: If you want to install Kali-Linux:
     

    Step 7: Launch Kali Linux

    Now we are ready to launch Kali Linux:

    Community Q&A