Skip to content

Windows Subsystem for Linux (WSL)

Windows Subsystem for Linux (WSL) allows developers to run a Linux environment directly on Windows without the overhead of a traditional virtual machine or dual-boot setup^[400-devops-02-os-and-linux-basics-windows-000-moc-windows.md, 400-devops-02-os-and-linux-basics-windows-wsl.md].

Installation

The manual installation process for WSL 2 involves enabling specific Windows features via the command line.^[400-devops-02-os-and-linux-basics-windows-wsl.md]

  1. Enable WSL: Run dism.exe to enable the "Microsoft-Windows-Subsystem-Linux" feature.
  2. Enable Virtual Machine Platform: Run dism.exe to enable the "VirtualMachinePlatform" feature.
  3. Update Kernel: Download and install the WSL2 Linux kernel update package.
  4. Set Default: Configure WSL 2 as the default version using wsl --set-default-version 2.^[400-devops-02-os-and-linux-basics-windows-wsl.md]

Interoperability

Command Line Integration

WSL supports executing Linux tools from the Windows command line.^[400-devops-02-os-and-linux-basics-windows-wsl.md] For example, running wsl ls -la in Windows PowerShell will list the contents of the current Windows directory using the Linux ls command.^[400-devops-02-os-and-linux-basics-windows-wsl.md]

To bridge the two filesystems, the command explorer.exe . can be used within the Linux environment to open the current directory in Windows File Explorer.^[400-devops-02-os-and-linux-basics-windows-wsl.md]

Networking

Networking between the two systems is handled via specific IP configurations: * Windows to Linux: Windows can access Linux networking applications using localhost.^[400-devops-02-os-and-linux-basics-windows-wsl.md] * Linux to Windows: Linux can access Windows networking applications using the host machine's IP address, which can be found by checking /etc/resolv.conf.^[400-devops-02-os-and-linux-basics-windows-wsl.md]

Distribution Management

WSL provides commands to manage the state and lifecycle of Linux distributions (distros).

Importing and Exporting

Distributions can be exported to a tar file and subsequently imported to a new location using the wsl --import and wsl --export commands.^[400-devops-02-os-and-linux-basics-windows-wsl.md] To permanently remove a registered distribution, the command wsl --unregister is used.^[400-devops-02-os-and-linux-basics-windows-wsl.md]

User Configuration

When working with specific distributions, users can manage credentials and configuration: * Termination: A running distro can be stopped using wsl --terminate <DistroName>.^[400-devops-02-os-and-linux-basics-windows-wsl.md] * User Management: It is possible to log in as the root user to change passwords or add new users (e.g., creating a user and setting them as the default in /etc/wsl.conf).^[400-devops-02-os-and-linux-basics-windows-wsl.md]

  • [[Docker]]
  • [[Git]]
  • Scoop

Sources

^[400-devops-02-os-and-linux-basics-windows-000-moc-windows.md] ^[400-devops-02-os-and-linux-basics-windows-wsl.md]