Install Linux on Windows with WSL
Table of Contents
This guide is for installing Ubuntu on WSL (Windows Subsystem for Linux) that lets you run Linux on Windows without using dual boot or traditional virtual machines.
Prerequisites
- A computer with Windows 10 (version 19041 or higher) or Windows 11.
- Latest graphics drivers. Try with Windows Update or here.
1. Install WSL command and Ubuntu
-
Go to Control Panel > Programs and Features > Turn Windows features on or off. Ensure that Virtual Machine Platform and Windows Subsystem for Linux are both checked then confirm. A reboot may be required at the end of the process.
-
Search for PowerShell in the Start menu, then right click on it and Run as administrator, type in the following command:
wsl --update wsl --install -d Ubuntu-22.04
This command will enable the features necessary to run WSL and install the Ubuntu 22.04 distribution of Linux. You can also install other Linux distributions from the Microsoft Store.
-
Follow the instructions on the screen to add your username and password for the Linux distribution.
-
Reboot your machine to complete the WSL2 install.
2. Verify installation
-
Open PowerShell or Windows Command Prompt in administrator mode by right-clicking and selecting Run as administrator, enter the wsl –list –verbose command to verify that the installation was successful.
wsl --list --verbose
-
To start Ubuntu, search for Ubuntu in the Start menu and click on the Ubuntu 22.04 app. Then, verify Ubuntu version entering the following command in the Ubuntu terminal.
lsb_release -a
3. Install Windows Terminal (optional)
Windows Terminal is a new, modern, feature-rich, productive terminal application for command-line users. If you don’t have it installed, you can install it from the Microsoft Store.
To open Ubuntu in Windows Terminal, click on the down arrow and select Ubuntu 22.04.
If you don’t see the Ubuntu profile click on the down arrow and select Settings or press Ctrl + ,
and do the following:
4. Increase available memory (optional)
WSL 2 defaults at using half of the RAM installed in your computer, for example if you have 8 GB of RAM the Linux Subsystem can use only 4 GB. If you need to increase this value because, for example, some ROS 2 packages will need more RAM to build, perform the following operations.
- In a PowerShell window type the following command, this will open the file
.wslconfig
in a Notepad windows so that you can edit it.New-Item $env:USERPROFILE/.wslconfig -type file -Force; notepad.exe $env:USERPROFILE/.wslconfig
- Add the following lines to the just opened file and save it.
[wsl2] memory=8GB # you can put as much as you want, up to the maximum installed in your system
- Restart WSL system typing the following line in a PowerShell window.
wsl --shutdown