How to Install Linux on Windows with WSL
Prerequisites
Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11.
Enable WSL
- Go to Search > Control Panel > Programs > Programs and Features > Turn Windows Features on or off
- Check the Windows Subsystem for Linux
- Click OK and it wil install necssarily files.
- After completed, click Restart now and the Windows will reboot.
Enable Sudo Mode
- Go to Settings > System > For Developers
- Switch Developer Mode on
- Enable Sudo on
- Exit from settings
Install WSL command
Open PowerShell or Windows Command Prompt in administrator mode by right-clicking and selecting "Run as administrator".
Enable the features necessary to run WSL and install the Ubuntu distribution of Linux.
wsl --install
then restart your machine.
After reboot windows, enter linux username and password.
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: me
New password:
Retype new password:
passwd: password updated successfully
Installation successful!
To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.
Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.68.1-microsoft-standard-WSL2 x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
This message is shown once a day. To disable it please create the
/home/me/.hushlogin file.
me@mypc:~$
Everything setup. Goodluck.
Change the default Linux distribution installed
To see a list of available Linux distributions:
wsl --list --online
or
wsl -l -o
To change the distribution installed or to install additional Linux distributions after the initial install:
wsl --install -d (Distribution Name)
Replace (Distribution Name) with the name of the distribution.
Check which version of WSL you are running
Open PowerShell or Windows Command Prompt:
PS C:\Users\me>
Check current WSL version installed:
wsl --version
or
wsl -v
Check installed Linux distributions:
wsl --list -v
or
wsl -l -v
Update WSL to latest version
wsl --update
Checking for updates.
The most recent version of Windows Subsystem for Linux is already installed.
Uninstall Linux distribution installed
wsl --unregister (Distribution Name)
Replace (Distribution Name) with the name of the distribution.
Backing up and importing to WSL
Export WSL:
wsl --export (Distribution Name) (Filename)
E.g:
wsl --export Debian debian-backup.tar
Import:
wsl --import (Distribution Name) (Install Location) (File Location and Filename)
E.g:
wsl --import Debian C:\Users\Me\AppData\Local\Packages\Debian C:\Users\Me\Documents\debian-backup.tar
Enable systemd support in WSL
Open PowerShell or Windows Command Prompt:
PS C:\Users\me>
Ensure that the right WSL version installed as WSL version 0.67.6 and higher needed:
wsl --version
Update WSL to latest version if not meet with requirement:
wsl --update
Get into Linux distro installed:
me@mypc:~$
Set the systemd flag set in WSL distro settings by editing the /etc/wsl.conf:
sudo nano /etc/wsl.conf
[boot]
systemd=true
Close WSL distro Windows from PowerShell to restart running WSL instances:
wsl.exe --shutdown
Get into Linux distro again and check the systemd is running:
systemctl list-unit-files --type=service