0 Comments

What the Windows Subsystem for Linux (WSL) Is vs. a Virtual Machine

The Windows Subsystem for Linux (WSL) is a powerful compatibility layer developed by Microsoft that allows you to run native Linux command-line tools, utilities, and applications directly on Windows—without the need for a traditional virtual machine (VM) or dual-boot setup. Introduced in Windows 10 and enhanced in Windows 11, WSL enables seamless integration between Windows and Linux environments.

Unlike a virtual machine, which runs a full Linux operating system inside a simulated hardware environment using software like VirtualBox or VMware, WSL operates at the kernel level. It translates Linux system calls into ones that Windows can understand, allowing Linux binaries to run natively alongside Windows processes. This eliminates the overhead of running a full guest OS, resulting in faster performance, lower memory usage, and quicker startup times.

Here are the key differences:

Feature WSL Virtual Machine
Resource Usage Low (shares kernel resources) High (dedicated CPU, RAM, disk)
Startup Speed Near-instant (seconds) Slower (1–3 minutes)
Integration with Windows Excellent (shared files, clipboard, network) Limited (requires shared folders or network)
GUI Application Support Available (with WSLg in WSL 2) Full support
Disk Space Minimal (1–2 GB per distro) Large (10–20 GB+)
Hardware Access Partial (via Windows) Full (with proper drivers)

WSL comes in two versions: WSL 1 and WSL 2. WSL 1 translates Linux system calls directly to Windows, while WSL 2 uses a lightweight utility VM with a real Linux kernel for better performance and full system call compatibility. Despite using a VM internally, WSL 2 is optimized for efficiency and feels just as fast as WSL 1 for most tasks.

In short, if you’re a developer, student, or Linux enthusiast who wants to use Bash, SSH, apt, and other Linux tools without leaving Windows, WSL is the ideal solution. It’s not meant to replace full VMs for complex server simulations or GUI-heavy Linux desktops, but it excels at command-line development, scripting, and learning Linux.

Tip: WSL is perfect for web development, Python scripting, Docker (via WSL 2 backend), and learning Linux commands—all without rebooting or managing a separate OS.

Step-by-Step Installation Tutorial from the Microsoft Store

Installing WSL has never been easier. Microsoft now hosts Linux distributions directly in the Microsoft Store, making setup fast and user-friendly. Follow these steps to get started:

  1. Enable WSL on Windows:
    Press Windows + X and select Windows PowerShell (Admin) or Terminal (Admin). Run:
    wsl –install
    This single command enables the necessary features, installs WSL 2, sets it as default, and downloads Ubuntu as the default distribution.
  2. Restart your computer:
    After the command finishes, restart your PC when prompted. This applies the necessary system changes.
  3. Launch your Linux distribution:
    After reboot, Windows will finish setting up Ubuntu. A terminal window will open asking you to:
    • Create a new username (e.g., john)
    • Set a password (you won’t see characters as you type)
    This account is separate from your Windows user and is used only within Linux.
  4. Alternative: Install from Microsoft Store manually:
    If the automatic install fails or you want a different distribution:
    1. Open the Microsoft Store.
    2. Search for Ubuntu, Debian, Kali Linux, or openSUSE.
    3. Click Get or Install.
    4. After download, click Launch to set up your user account.
  5. Verify installation:
    Open Start and search for your Linux distro (e.g., “Ubuntu”). Click it to launch the terminal. You should see a prompt like:
    john@DESKTOP-XXXXXX:/mnt/c/Users/john$
    This means WSL is working correctly.

You can now run Linux commands, install software via apt, and access your Windows files—all from a terminal that starts in seconds.

Optional: To install WSL manually (for older Windows versions), run:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-VirtualMachinePlatform /all /norestart
Then restart and set WSL 2 as default with wsl --set-default-version 2.

Warning: Ensure your Windows 10 version is 2004 or higher (Build 19041+) or use Windows 11 for best compatibility. Older versions may not support WSL 2.

The 10 Basic Linux Commands You Need to Know to Get Started

Once WSL is installed, you’ll interact with it using the Linux terminal. Here are the 10 essential commands every beginner should learn:

  1. pwd – Print Working Directory
    Shows your current location in the file system.
    pwd
  2. ls – List files and directories
    Displays contents of the current folder.
    Use ls -la to show hidden files and details.
    ls
    ls -la
  3. cd – Change Directory
    Navigate between folders.
    cd Documents
    cd .. # Go back one level
    cd ~ # Go to home directory
  4. mkdir – Make Directory
    Create a new folder.
    mkdir projects
  5. touch – Create a file
    Creates an empty file.
    touch notes.txt
  6. cat – Display file contents
    Shows the content of a file.
    cat notes.txt
  7. cp – Copy files
    Copies a file to another location.
    cp file1.txt file2.txt
  8. mv – Move or rename files
    Renames or moves a file.
    mv oldname.txt newname.txt
    mv file.txt ~/Documents/
  9. rm – Remove files
    Deletes a file (use carefully!).
    rm unwanted.txt
    Use rm -r foldername to delete a directory and its contents.
  10. sudo apt update && sudo apt upgrade – Update system packages
    Updates the package list and upgrades installed software (Ubuntu/Debian).
    sudo apt update
    sudo apt upgrade

These commands form the foundation of Linux navigation and file management. Practice them in your WSL terminal to build confidence. Remember: Linux is case-sensitive, so MyFile.txt and myfile.txt are different.

Tip: Use the Tab key to auto-complete filenames and commands. Press Up/Down arrow to cycle through command history.

How to Access Your Windows Files from the Linux Terminal

One of WSL’s most powerful features is seamless file system integration. You can access your entire Windows file system directly from the Linux environment.

In WSL, Windows drives are mounted under /mnt/. For example:

  • /mnt/c/ → Your C: drive
  • /mnt/d/ → D: drive (if present)
  • /mnt/c/Users/YourName/Desktop → Your Windows Desktop
  • /mnt/c/Program Files → Program Files folder

To navigate to your Windows Desktop:

cd /mnt/c/Users/john/Desktop
Replace john with your actual Windows username.

You can read, edit, and create files from Linux that appear instantly in Windows Explorer. For example:

echo “Hello from Linux!” > /mnt/c/Users/john/Desktop/hello.txt
This creates a file on your Windows Desktop using the Linux terminal.

Conversely, you can access your Linux files from Windows at:

\\wsl$\Ubuntu\home\john
Open File Explorer and paste this path to browse your Linux home directory. You can copy files back and forth seamlessly.

However, avoid editing Linux system files (like those in /etc or /usr) using Windows apps. File permission and line-ending differences can cause issues. Always use Linux tools (e.g., nano, vim) when working inside the WSL environment.

You can also launch Windows programs from WSL. For example:

notepad.exe myfile.txt
explorer.exe .
The first opens a file in Notepad; the second opens the current folder in Windows Explorer.

Warning: Do not move or delete files in /mnt/c/Windows, /mnt/c/Program Files, or system folders. This can break Windows or installed applications.

Installing a Distribution Like Ubuntu in Less Than 10 Minutes

Installing a Linux distribution such as Ubuntu via WSL is incredibly fast and straightforward. From start to finish, the entire process takes less than 10 minutes on a stable internet connection.

Step-by-Step Timeline (Under 10 Minutes)

  1. 0–2 min: Open PowerShell as Admin
    Search for “PowerShell”, right-click, and choose “Run as administrator”.
  2. 2–3 min: Run the Install Command
    Type:
    wsl –install -d Ubuntu
    This installs only Ubuntu, skipping the default if multiple distros are available.
  3. 3–6 min: Download and Extract
    Windows downloads the Ubuntu package from the Microsoft Store and sets up the filesystem. No user input needed.
  4. 6–7 min: Restart Your PC
    After installation, restart when prompted. This enables WSL 2 and the virtual machine platform.
  5. 7–9 min: Set Up Your Linux User
    After reboot, Ubuntu launches automatically. Create your username and password when prompted.
  6. 9–10 min: Update Packages
    Run:
    sudo apt update && sudo apt upgrade -y
    This ensures your system is up to date.

That’s it! You now have a fully functional Ubuntu environment running inside Windows. You can:

  • Install Python, Node.js, Git, and other dev tools with apt.
  • Run a web server with python3 -m http.server 8000.
  • Edit files using nano script.py or vim app.js.
  • Use SSH to connect to remote servers.

To install other distributions, replace Ubuntu with:

  • Debian
  • Kali-Linux
  • openSUSE-Leap
  • Arch (via manual install)

You can even run multiple distributions simultaneously. Each has its own filesystem and settings, but all share the same WSL backend.

WSL transforms Windows into a hybrid development platform, combining the familiarity of Windows with the power of Linux. Whether you’re learning Bash, building web apps, or exploring cybersecurity tools, WSL provides a smooth, efficient, and integrated experience—no virtualization overhead required.

Final Tip: Keep WSL updated by running wsl --update periodically. This ensures you have the latest kernel and security patches.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts