Windows Subsystem for Linux (WSL) Tips
Posted October 1, 2024
By Kevin Schwickrath1 min read
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
wsl --installSelect the distribution
In Windows Terminal, you can list the available distribution.
wsl --list --onlineInstall your desired image either with the following command.
wsl --install -d <Distribution Name>This command will install Ubuntu-24.04 in the specified directory with the distribution name of newdistro.
wsl --install Ubuntu-24.04 --location "C:\Users\Kevin\WSL\newdistro" --name newdistroStart the distribution
wsl -d newdistroSetup your distribution
Create your user account and password.
PS C:\Users\Kevin\WSL> wsl --install Ubuntu-24.04 --location "C:\Users\Kevin\WSL\newdistro" --name newdistroDownloading: Ubuntu 24.04 LTSInstalling: Ubuntu 24.04 LTSDistribution successfully installed. It can be launched via 'wsl.exe -d newdistro'PS C:\Users\Kevin\WSL> wsl -d newdistroProvisioning the new WSL instance newdistroThis might take a while...Create a default Unix user account: kevinNew password:Retype new password:passwd: password updated successfullyTo 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.
vi /etc/wsl.confI typically use the following options in my config file.
[boot]systemd=true[network]hostname=newdistro[user]default=kevinShutdown the image
Once you have made your initial changes, stop the distribution.
wsl --shutdown UbuntuDev2Shutdown all the running distributions
Side tip: if you want to shut down all the distributions, use the following command.
wsl --shutdownVerify distribution states
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 2Restart the distribution and login
wsl -d UbuntuDev2Updates
Don’t forget to run your updates.
sudo apt update
sudo apt upgradeCheck your release info with this command:
kevin@Dev2:~$ cat /etc/os-releasePRETTY_NAME="Ubuntu 24.04.1 LTS"NAME="Ubuntu"VERSION_ID="24.04"VERSION="24.04.1 LTS (Noble Numbat)"VERSION_CODENAME=nobleID=ubuntuID_LIKE=debianHOME_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=nobleLOGO=ubuntu-logoHave fun!
Sources / Linkage
This post is licensed under CC BY 4.0 by the author.
Related Posts
Mounting Azure LUN Drives or Data Disks in Ubuntu 24.04
I play in the "cloud," and sometimes my cloud needs additional storage. Azure data disk or LUN storage is inexpensive and easy. Here is how I mounted my…
Manually Update VMWare ESXi
VMWare is in the news again. I feel the next 24 months will be rough for security teams across the board. Many have spent the last year or more in…