WSL2 Full Overview

Jul 4, 2024

Windows Subsystem for Linux (WSL) Lecture

Introduction to WSL

  • WSL allows running Linux on Windows and vice versa.
  • Demonstrated running Ubuntu and Kali Linux on Windows.
  • Offers GUI support, GPU access, and shared files between Windows and Linux.
  • Enables use of Linux commands on Windows and Windows commands on Linux.
  • WSL2 is the latest version, offering better performance and features.

Installation Requirements

Hardware Requirements

  • 64-bit processor (ARM supported).
  • Minimum of 4GB RAM (16GB or higher recommended for best performance).
  • Enable virtualization in BIOS (Intel VTx or AMD-V).

Software Requirements

  • Must be running Windows (best experience on Windows 11).
  • Windows 10 supported on build 19041 or higher.
  • Admin privileges needed.

Installing WSL2

  • Open Windows Terminal, type WSL --install.
  • Default installation includes Ubuntu. Restart required.
  • Set up a username and a password upon first launch.

Using WSL2

  • Start WSL by typing WSL -d Ubuntu (or your distro's name).
  • List available distros using WSL --list --online.
  • Additional distros (e.g., Kali Linux) can be installed from Microsoft Store.
  • Example of installing Kali Linux using the command line and Microsoft Store.

Features and Commands

Running Windows Commands in Linux

  • Use Windows commands like ipconfig, ping.exe, and notepad.exe.
  • Open current location in Windows Explorer: explorer.exe .

Running Linux Commands in Windows PowerShell

  • Pipe commands using WSL, e.g., ipconfig | WSL grep 10..
  • Commands like cat can be used with WSL, e.g., WSL cat file.txt.

Kali Linux Tools Setup

  • Run kali-tweaks to access tool installation menu.
  • Example: Install top 10 Kali Linux tools.

Data Privacy Concerns

  • Mentioned SpiderFoot tool for OSINT (Open-Source Intelligence).
  • Discussion about the vulnerability of personal data on sites like TruthFinder.
  • Introduction to Incogni service to remove personal information from public databases.
  • Steps to sign up and use Incogni.

WSL Functionalities

  • Enable or disable WSL instances using commands.
  • Example commands: WSL --shutdown, WSL --terminate distro_name.
  • Listing distributions with verbose output: WSL --list --verbose.
  • Setting default distro: WSL --set-default distro_name.

File Management

Accessing Files

  • Access Windows files from Linux: cd /mnt/c/Users/username.
  • Access Linux files from Windows Explorer via explorer.exe .
  • Linux files also accessible from Windows' left-hand sidebar under

GUI Applications

  • WSL2 supports GUI applications via WSLg.
  • Running GUI applications like Wireshark and Google Chrome from Linux on Windows.

GPU Access

  • WSL2 allows direct access to GPU, e.g., Nvidia-smi.

Advanced Configurations

Config Files

  • Two config files: local wsl.conf and global wslconfig.
  • Local config located in /etc/wsl.conf. Used for system-wide settings.
  • Global config (wslconfig) found in user directory in Windows.
  • Example: changing networking mode from NAT to mirrored.

Networking Mode Example

  • Default networking mode is NAT; setup for mirrored mode shown:
    [WSL2]
    networkingMode = mirrored
    
  • Importance of waiting 8 seconds after shutdown for changes to take effect.

Backing Up and Importing Distros

  • Command to export distro: WSL --export distro_name filename.tar.
  • Command to import distro on another machine: WSL --import new_distro location filename.tar.
  • Specify user account to avoid root default: WSL -d distro -u username.

Visual Studio Code Integration

  • Use code command to open files from Linux in VS Code.
  • Install WSL extension for better integration.

Docker Support

  • Docker can be run inside WSL2.
  • Install Docker Desktop as another method using WSL2 as backend.

Conclusion

  • WSL2 combines Windows and Linux, offering powerful functionalities.
  • Further capabilities include running Docker, accessing GPU, and sophisticated file management.
  • Enable users to optimize development and operational workflows.

Presenter: Network Chuck Source: Network Chuck's WSL2 Tutorial and Demonstration