How to Install Windows WSL (Windows Subsystem for Linux)

Mar 31, 2024 - Leave a Comment

Installing Windows WSL

If you’re a Windows user, whether on a PC, in a dual boot environment with Boot Camp on an Intel Mac, or you’re running Windows 11 in a virtual machine on an Apple Silicon Mac, you may have an interest in installing Windows Subsystem for Linux, or WSL.

Windows Subsystem for Linux puts a full Ubuntu Linux shell on a Windows PC that is accessible from the command prompt or PowerShell. If you have a Mac background, you can think of Windows WSL as kind of like what Terminal and HomeBrew is for MacOS, since MacOS has a BSD shell available at any time through the command line.

Requirements for installing Windows WSL

Your Windows installation must be Windows 10 version 2004 or higher (build 19041 and later) or any version of Windows 11 or later.

This applies the same to Windows on a PC, a Mac in Boot Camp, or within a virtual machine.

How to Install Windows WSL

It doesn’t matter if you’re installing Windows WSL onto a PC, into Boot Camp, or into a virtual machine where running Windows in a VM over MacOS, it’s all the same.

  1. From Windows, open the Command Prompt or PowerShell from the Windows/Start menu, or by clicking the search button in the taskbar, and typing “cmd”, and then selecting to “Run as administrator”
  2. Now at the Windows Command Prompt, type the following command:
  3. wsl --install

  4. Hit the return key to begin installing Windows Subsystem for Linux, the default installation is Ubuntu, allow the installation if asked
  5. After installation has finished, you can launch into WSL by typing the following in Command Prompt or PowerShell:
  6. wsl

  7. Once in wsl, use any linux or unix command as usual

Once WSL has installed in Windows, you’ll find the world of Linux and unix apps and tools are available, making many command line tips relevant and usable. For example, you can run ‘top’ to watch processes resource usage, or use ‘ls -la’ for a long directory list.

Installing Linux/Unix Apps into WSL

Once WSL has installed in Windows, you can then use the WSL command line to install and use other linux and unix apps. The package manager for installing apps with Ubuntu, and thus the default WSL installation, is ‘apt’, which, if you’re coming from a Mac background, is very similar to Homebrew. To use apt to install a tool, package, or application into WSL, use the following syntax:

sudo apt install (appname)

For example, to install ‘htop’ into WSL, you would use the following command:
sudo apt install htop

Many of the command line tips and tricks that we have covered use general unix commands, meaning they work not only on the Mac as typically covered here, but also for Linux, FreeBSD, Windows WSL, and many other Unix variations and subsystems.

Going further into Windows WSL & Unix Command Line

You can customize the WSL installation if you’d like to, or even use a different linux distribution aside from Ubuntu, but that’s largely unnecessary for the vast majority of users who will be engaging with WSL, thus beyond the scope of what we’re covering here.

If you’re interested in learning more specifically about WSL, check out the Microsoft documentation here.

If you want to find some fascinating tips, tricks, and other interesting things you can accomplish at the command line, often not only on the Mac but also at any unix prompt like WSL, check out our terminal tips here.

.

Related articles:

Posted by: Paul Horowitz in Command Line, Tips & Tricks

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site