Skip to main content

WSL

WSL (Windows Subsystem for Linux) is a compatibility layer developed by Microsoft that allows you to run a GNU/Linux environment (like Ubuntu, Debian, Kali, etc.) directly on Windows, without needing a virtual machine (VM) or dual-boot setup.

It lets developers and system admins use Linux tools (like bash, grep, sed, awk, etc.) alongside their Windows apps.

Key Features of WSL

  1. Run Linux inside Windows – Access Linux terminal and tools directly from Windows.

  2. No Virtual Machine overhead – Unlike VMware or VirtualBox, WSL is lightweight and efficient.

  3. Direct file access – You can access Windows files from Linux and vice versa.

    • From Linux: /mnt/c/Users/...
    • From Windows: \\wsl$\<distro_name>
  4. Supports Linux commands & software – You can install software via apt, dnf, or other Linux package managers.

  5. Interoperability – Run Linux commands inside Windows and Windows executables inside Linux (explorer.exe, notepad.exe).

  6. Two Versions:

    • WSL 1 → Uses a translation layer, slower for I/O.
    • WSL 2 → Uses a lightweight virtualized Linux kernel, faster, supports Docker & full system calls.

Installing WSL

Search Windows feature on or off in the search bar and enable Windows subsystem for linux and Virtual Machine Platform

Step 1: Enable WSL

Open PowerShell as Administrator and run:

wsl --install

This installs the latest version of WSL (by default WSL 2) with Ubuntu.

Step 2: Check installed distributions

wsl --list --verbose

Example Output:

  NAME      STATE           VERSION
* Ubuntu Running 2

Step 3: Launch Linux

From PowerShell or CMD:

wsl

Or open Ubuntu from Start Menu.

Basic Usage Examples of WSL

1. Running Linux Commands

Inside WSL terminal:

ls -la
pwd
uname -r
  • ls -la → lists files with details
  • pwd → prints current directory
  • uname -r → shows Linux kernel version

2. Accessing Windows Files from Linux

cd /mnt/c/Users/YourName/Desktop
ls

This shows your Windows Desktop files from Linux.

3. Accessing Linux Files from Windows

In Windows Explorer, type:

\\wsl$\Ubuntu\home\your_username

This opens your Linux home directory from Windows.

4. Running Windows Programs inside Linux

notepad.exe myfile.txt
explorer.exe .
  • Opens myfile.txt in Notepad (Windows).
  • Opens current Linux directory in Windows File Explorer.

5. Installing Linux Packages

Example: Installing Git and Node.js in WSL:

sudo apt update
sudo apt install git nodejs -y

WSL for Development

Suppose you are a web developer:

  1. Install Ubuntu with WSL:
wsl --install -d Ubuntu

wsl -l -o return all the available distrubution 2. Inside Ubuntu, install Nginx and start server:

sudo apt update
sudo apt install nginx -y
sudo service nginx start
  1. Open browser in Windows → visit http://localhost → Nginx welcome page appears (because WSL shares the same network).

This allows you to develop Linux-based applications directly from Windows.

Why we need to install Redis

Redis was originally built for Linux/Unix systems, not Windows. While there used to be a Windows port years ago, it’s no longer officially maintained. That’s why, on Windows 10 or 11, the easiest and most reliable way to run Redis is through Linux — and that’s exactly what WSL provides.