Skip to content
💻 🧠 Code 1001 > 🧪📓 Uncategorized > WSL: Linux on Windows

WSL: Linux on Windows

Want to use Linux tools (Docker, Python, Node.js) without leaving Windows? Meet WSL (Windows Subsystem for Linux). It is a full Linux kernel running in parallel with your primary system.

Before you begin, check your BIOS settings. Virtualization (VT-x or AMD-V) must be enabled. Without this, Linux will not launch.

Let’s look at how to set up both systems to work together seamlessly.


1. Checking the Status

Before starting, check your current system state in PowerShell:

wsl -l -v

wsl -l -v returns a list of installed distributions:

  • Empty response: No distributions installed.
  • Ubuntu: Linux is already installed.
  • docker-desktop / docker-desktop-data: Technical distributions for Docker Desktop.

⚠️ The VERSION column should show 2. If it shows 1, update the distribution using the command wsl --set-version Ubuntu 2.


2. Installation

If Linux is not installed, run PowerShell as an administrator and enter:

wsl --install

The system will prepare Ubuntu. Once finished, restart your computer to finalize the kernel configuration.


3. User Setup

Upon the first launch, WSL will prompt you to create a user. If you see root@PC_NAME in the terminal—that is normal.

Root is required for system settings; create a separate user for development.

Note ⚠️: The tilde symbol ~ represents the home directory path. For root, it is /root; for a regular user, it is /home/your_username. If you create projects under root, you will encounter permission issues in VS Code. The command cd ~/projects will lead to different locations for root and a regular user.

How to create a user:

# Create user your_username
adduser your_username
# Grant administrative privileges (for sudo)
usermod -aG sudo your_username

To ensure WSL always opens with your username, enter this in Windows PowerShell:

# Replace your_username with your actual username
ubuntu config --default-user your_username

The terminal will now greet you with: your_username@PC_NAME:~$.


4. Where to Store Code

WSL can access Windows drives (/mnt/c/), but do not store your projects there.

Windows and Linux file systems communicate slowly. Storing projects on the C: or D: drive will significantly slow down your work with code.

The correct place: your Linux home folder.
Enter:

cd ~
mkdir projects && cd projects

This ensures maximum speed. To open the folder in Windows Explorer: explorer.exe .


5. Tech Stack

Python (venv)

Isolate packages in Linux. Do not install libraries globally; use virtual environments:

sudo apt update && sudo apt upgrade -y
sudo apt install python3-pip python3-venv -y

# Project setup
mkdir my_project && cd my_project
python3 -m venv venv
source venv/bin/activate

Node.js (NVM)

The standard apt install nodejs often installs an outdated version. Use NVM (Node Version Manager):

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install --lts    # Installs the latest stable version

6. Integration

VS Code

Install VS Code on Windows and the Remote – WSL extension. Running code . in the Ubuntu terminal will open the project in the Windows interface, while the code executes inside Linux.

Docker

In Docker Desktop settings (Settings -> Resources -> WSL Integration), enable the checkbox for Ubuntu. You can now manage containers directly from the Linux terminal.


7. Daily Cheat Sheet

  • whoami — Check if you are root or a regular user.
  • pwd — Full path to the current folder.
  • wsl --shutdown — (In PowerShell) Fully stop Linux to clear RAM.
  • cat file.txt | clip.exe — Copy text from Linux to the Windows clipboard.

Workflow:

  1. Open terminal. You see: your_username@....
  2. Enter project: cd ~/projects/my-app.
  3. Launch VS Code: code ..
  4. Profit.

Your system is now professionally configured.

Leave a Reply

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