Windows Subsystem for Linux (WSL) Tips
WSL lets you install a Linux distribution (such as Ubuntu) to use Linux command-line tools directly on Windows. You get Linux with a real Linux kernel right from Terminal. In my examples I’m using Windows 11.
Easy install
First, ensure your BIOS options are enabled. You will need to turn on the virtualization features if they are not enabled by default. Next, head over to the the Microsoft Store and search for the distribution you want.
Setup WSL via CLI
Open Terminal and type
1
wsl --install
Select the distribution
In Windows Terminal, you can list the available distribution.
1
wsl --list --online
Install your desired image either with the following command.
1
wsl --install -d <Distribution Name>
This command will install Ubuntu-24.04
in the specified directory with the distribution name of newdistro
.
1
wsl --install Ubuntu-24.04 --location "C:\Users\Kevin\WSL\newdistro" --name newdistro
Start the distribution
1
wsl -d newdistro
Setup your distribution
Create your user account and password.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
PS C:\Users\Kevin\WSL> wsl --install Ubuntu-24.04 --location "C:\Users\Kevin\WSL\newdistro" --name newdistro
Downloading: Ubuntu 24.04 LTS
Installing: Ubuntu 24.04 LTS
Distribution successfully installed. It can be launched via 'wsl.exe -d newdistro'
PS C:\Users\Kevin\WSL> wsl -d newdistro
Provisioning the new WSL instance newdistro
This might take a while...
Create a default Unix user account: kevin
New password:
Retype new password:
passwd: password updated successfully
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Thu Feb 27 21:14:10 CST 2025
System load: 0.43 Processes: 31
Usage of /: 0.1% of 1006.85GB Users logged in: 0
Memory usage: 1% IPv4 address for eth0: 192.168.230.185
Swap usage: 0%
This message is shown once a day. To disable it please create the
/home/kevin/.hushlogin file.
Edit the WSL config
WSL has many configuration options. Advanced settings configuration in WSL | Microsoft Learn
Use vi or a similar editor to edit the file.
1
vi /etc/wsl.conf
I typically use the following options in my config file.
1
2
3
4
5
6
[boot]
systemd=true
[network]
hostname=newdistro
[user]
default=kevin
Shutdown the image
Once you have made your initial changes, stop the distribution.
1
wsl --shutdown UbuntuDev2
Shutdown all the running distributions
Side tip: if you want to shut down all the distributions, use the following command.
1
wsl --shutdown
Verify distribution states
1
2
3
4
5
6
PS C:\Users\Kevin> wsl --list --all -v
NAME STATE VERSION
* Ubuntu Running 2
UbuntuDev1 Stopped 2
docker-desktop-data Stopped 2
docker-desktop Stopped 2
Restart the distribution and login
1
wsl -d UbuntuDev2
Updates
Don’t forget to run your updates.
1
2
3
sudo apt update
sudo apt upgrade
Check your release info with this command:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
kevin@Dev2:~$ cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.1 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
Have fun!
Comments powered by Disqus.