Microsoft’s Windows Subsystem for Linux version 2, better known as WSL2, is a revolutionary feature that offers the opportunity for developers to run a Linux environment directly on Windows, without the need for a traditional dual-boot or virtual machine setup. This integration means you can use Linux command-line tools and utilities right within your Windows 11 environment. In this comprehensive guide, we will show you how to quickly start, restart, or shutdown WSL2 on your Windows 11 system.
Before you can use WSL2, you first need to ensure it is installed and enabled on your Windows 11 system. If you haven’t done this yet, you can refer to the official Microsoft documentation for a step-by-step guide to installing WSL2.
Once you have confirmed that WSL2 is installed, starting it up is a straightforward process. First, you need to open the
Command Prompt or
PowerShell in administrator mode. You can do this by right-clicking on the Start button and choosing either “Command Prompt (Admin)” or “PowerShell (Admin)”.
With your Command Prompt or PowerShell open, you simply need to type the following command to start your WSL2:
This command initiates the default Linux distribution you’ve installed on your system. If you have installed multiple distributions and you want to launch a specific one, you need to use the
-d flag followed by the name of the distribution. So, to launch Ubuntu, you would type:
wsl -d Ubuntu
There are several methods to restart WSL2 on Windows 11:
- The Shutdown and Restart Method: The simplest way is to shut down WSL2 and start it again. First, shut down WSL2 (covered in the next section) and then start it as outlined above.
- The LxssManager Service Method: You can restart the LxssManager service, which controls the operation of WSL2. To do this, press
Win + Rto open the Run dialog box, type
services.msc, and hit Enter.
This will open the Services console. Scroll down to find the
LxssManagerservice, right-click on it, and choose
- The PowerShell Command Method: Alternatively, you can use PowerShell to restart the LxssManager service directly. Open PowerShell in administrator mode and type the following command:
Get-Service LxssManager | Restart-Service
This command fetches the LxssManager service and pipes it to the
Restart-Servicecommand, effectively restarting the service and, consequently, WSL2.
Shutting down WSL2
When you’re done with your work in the Linux environment, or when you want to restart it, shutting down WSL2 is necessary. To do this, you need to open the
Command Prompt or
PowerShell just like before. Then, type the following command:
This command effectively shuts down the WSL2 VM completely. It’s good practice to shut down WSL2 when you’re not using it, as it helps to free up system resources.
Linked issue: This App is Preventing Shutdown or Restart
Precautions before shutting down
It’s worth mentioning that when you shut down WSL2, it’s akin to shutting down a physical machine. This means that any unsaved work within the Linux environment will be lost. Therefore, it’s important that before you shut down WSL2, you make sure to save all your work and close any running applications or processes that you don’t want to interrupt.
Harnessing the power of WSL2 on your Windows 11 system opens up a world of possibilities. It’s like having two operating systems on the same computer without the hassle of switching back and forth. The ability to start, restart, or shut down WSL2 at will means you have the flexibility to access a Linux environment when you need it and conserve system resources when you don’t.
Mastering these processes might seem like a small step, but it’s fundamental in navigating the combined Windows and Linux landscape. Just remember to save your work before shutting down, much like you would when turning off your computer. Always refer back to official Microsoft documentation for up-to-date information, additional details, and troubleshooting advice.