Ever needed a Linux environment to learn development but wondered how to get one on a Windows PC? In the past, you might have set up dual booting or installed a virtual machine.
Windows Subsystem for Linux (WSL)
makes it easy to use Linux within Windows.
This guide shows how to install
Ubuntu
, a popular Linux distribution, using its stable long-term support release,
Before installing it, let's look briefly at what WSL does.
Windows Subsystem for Linux (WSL)
is a Windows feature that lets you run Linux executables directly from Windows. It gives you a Linux environment without having to manage a separate full virtual machine. There are two main versions.
WSL 1
translates Linux system calls so the Windows NT kernel can handle them. It has some limitations, including file system performance.
WSL 2
runs a real Linux kernel in a lightweight virtual machine. This greatly improves system call compatibility and file system performance in Linux workloads. WSL 2 is recommended for most users.
The Ubuntu distribution in this guide also works well under WSL 2.
First, enable the Windows features WSL needs. Think of it like putting batteries into a new toy. The easiest way is to run a command in PowerShell as an administrator.
Run PowerShell as administrator
Right-click the Windows Start button.
Select Windows PowerShell (Admin) or Terminal (Admin). The name varies with the Windows version.
Click Yes if prompted by User Account Control.
Enter the WSL installation command
Enter the following command in the administrator PowerShell window and press Enter. This enables the components WSL needs and may also install the default Linux distribution, usually a recent Ubuntu LTS release.
wsl --install
Running wsl --install without specifying a distribution installs the default Ubuntu release. Since we're aiming for
Ubuntu 22.04.1 LTS
, you can let the default installation proceed or pick the release you want from the Microsoft Store later.
If wsl --install doesn't work, or if you're on an older Windows version with only some WSL components installed, you may need to enable the features manually. Run the following commands in order.
after running both commands so the changes take effect.
Restart your computer
Whether you used wsl --install or enabled the features manually, restart Windows if the installer asks you to.
Optional: Set WSL 2 as the default
The current wsl --install command usually sets WSL 2 as the default. If you previously used WSL 1 or want to set the default explicitly, reopen PowerShell as an administrator after restarting and run the following.
wsl --set-default-version 2
If you see โWSL 2 requires an update to its kernel component,โ follow the link in the message, usually https://aka.ms/wsl2kernel, and install the Linux kernel update package.
Your Windows PC is now ready to run Linux.
Step 2: Install Ubuntu 22.04 LTS from the Microsoft Store ๐
If the WSL command installed Ubuntu already, you can proceed to the next step. To choose another Linux distribution or release, use the Microsoft Store.
Now let's install
Ubuntu 22.04 LTS
. The easiest option is the Microsoft Store, much like downloading an app on a phone.
Open the Microsoft Store
Search for Microsoft Store in the Windows Start menu and open it.
Find Ubuntu
Search for Ubuntu in the store. You may see several versions. Choose
Ubuntu 22.04 LTS
for this guide.
If you don't see that exact listing, try searching for Ubuntu 22.04 LTS specifically or select Ubuntu, which normally points to the latest LTS release. You can check the exact version after installation.
Install it
Click Install or Get on the page for the release you chose. The store downloads and installs it automatically. This may take a while depending on your connection. WSL lets you install and use multiple Linux distributions on the same machine.
After installing Ubuntu, launch it once to complete setup. Like naming a character when you start a game, you'll need to create a username and password for Linux.
Launch Ubuntu
Open Ubuntu 22.04.1 LTS, or the Ubuntu release you installed, from the Windows Start menu.
You can also launch it from PowerShell or Command Prompt with wsl or ubuntu2204.1. The launcher varies by distribution. Check installed distributions with wsl -l -v.
Wait for initial setup
On first launch, you may see โInstalling, this may take a few minutes...โ while setup runs.
Choose a username
When you see โEnter new UNIX username:โ, enter the name you want to use in Linux. Stick with lowercase English letters and numbers, as in student, myubuntu, or devuser.
๐๏ธ
Avoid spaces and special characters. Your Linux username can differ from your Windows username.
Press Enter to continue.
Choose a password
At โNew password:โ, enter a password for the Linux account. Nothing appears on screen as you type, including asterisks (*). Type it carefully and press Enter.
Confirm the password
At โRetype new password:โ, enter the same password again and press Enter. The characters will remain hidden. On success, you should see โPassword updated successfullyโ or a similar message, followed by a Linux prompt such as ์ฌ์ฉ์์ด๋ฆ@์ปดํจํฐ์ด๋ฆ:~$, where the two parts are your username and computer name.
Ubuntu running after setup
Ubuntu 22.04 LTS is now set up on Windows. If the prompt is visible, you're in the Linux terminal.
Step 4: Verify the Installation and Try Basic Commands ๐
Now check that everything works and try a few commands.
Check the Ubuntu version
Run the following command in the Ubuntu terminal.
lsb_release -a
It shows details about the installed Linux distribution. Check that Description: shows Ubuntu 22.04.5 LTS or a similar value. The Codename: should be jammy, short for Jammy Jellyfish.
Checking the Ubuntu version
Update the package list and upgrade installed packages
It's a good idea to update a new Linux installation. First refresh the list of available packages.
sudo apt update
If asked for your Linux password, type it and press Enter. It won't appear on screen. sudo stands for โsuperuser doโ and runs the command with administrator privileges.
Next upgrade installed packages.
sudo apt upgrade
This can take a while if many packages need upgrades. When prompted with [Y/n], type Y and press Enter.
Try a few Linux commands
ls lists files and subdirectories in the current directory.
pwd prints the full path of your current directory.
cd [๋๋ ํ ๋ฆฌ๋ช ] changes to the specified directory. For example, cd /home changes to /home.
mkdir [์๋๋ ํ ๋ฆฌ๋ช ] creates a directory with the name you supply.
clear clears the terminal.
Access Windows files
WSL makes it easy to access the Windows file system. Go to this path in your Ubuntu terminal.
cd /mnt/c
This takes you to the root of the Windows C drive. Run ls to see familiar directories such as Program Files, Users, and Windows. If you have a D drive, you can access it at /mnt/d.
We installed Ubuntu 22.04.1 LTS on Windows with WSL and completed the basic setup. You can now use a Linux development environment alongside your Windows tools.