{"id":1678,"date":"2022-08-18T16:02:43","date_gmt":"2022-08-18T14:02:43","guid":{"rendered":"https:\/\/nguenkam.com\/blog\/?p=1678"},"modified":"2022-08-18T16:02:43","modified_gmt":"2022-08-18T14:02:43","slug":"how-to-install-linux-wsl2-on-windows-10-and-windows-11","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2022\/08\/18\/how-to-install-linux-wsl2-on-windows-10-and-windows-11\/","title":{"rendered":"How to install Linux WSL2 on Windows 10 and Windows 11"},"content":{"rendered":"\n<p>Windows Subsystem for Linux (WSL) is a way to run actual Linux inside Windows without the need to set up a virtual machine. The project has seen a ton of support, and WSL2 is the latest and greatest.<\/p>\n\n\n\n<p>There is now a new, extremely simplified way to get WSL2 up and running on your Windows 10 and Windows 11 PC. The only requirement is that you&#8217;re running version 2004 of Windows 10 and above.<\/p>\n\n\n\n<p>open up PowerShell and enter this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wsl --install<\/code><\/pre>\n\n\n\n<p>That&#8217;s it. The setup process will begin and you can relax until it&#8217;s finished.<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4>How to enable Windows Subsystem for Linux<\/h4>\n\n\n\n<p>Before you can get WSL2, you need to have WSL. That may sound slightly strange, but the methods of enabling the first iteration and the second are quite different. But to have the newest version, you first need to have the first. There&#8217;s no direct path to just installing WSL2<\/p>\n\n\n\n<p>After you have installed WSL (first step, above) , Open PowerShell as administrator and enter this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dism.exe \/online \/enable-feature \/featurename:Microsoft-Windows-Subsystem-Linux \/all \/norestart<\/code><\/pre>\n\n\n\n<p>Eventually, you will need to reboot your PC, but you can leave it until later if you&#8217;re going straight to installing WSL2.<\/p>\n\n\n\n<p><span class=\"has-inline-color has-vivid-red-color\"><strong>PS:<\/strong><\/span><em> Now you have the Windows Subsystem for Linux enabled. It&#8217;s time to download and install WSL2.<\/em><\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4>How to install WSL2 on Windows 10<\/h4>\n\n\n\n<p>There are also a couple of pre-requisites for using WSL2 on Windows 10. You need to be on the following versions:<\/p>\n\n\n\n<ul><li><strong>For x64 systems<\/strong>: Version 1903 or higher, with Build 18362 or higher.<\/li><li><strong>For ARM64 systems<\/strong>: Version 2004 or higher, with Build 19041 or higher.<\/li><\/ul>\n\n\n\n<p>If you have anything lower, you&#8217;ll need to run Windows Update before going any further.<\/p>\n\n\n\n<p>Assuming that&#8217;s all good, the rest is straightforward.  &#8212;> <em><span class=\"has-inline-color has-vivid-cyan-blue-color\">enabling Virtual Machine and install WSL2<\/span><\/em><\/p>\n\n\n\n<h5><span class=\"has-inline-color has-luminous-vivid-orange-color\">Enabling Virtual Machine<\/span><\/h5>\n\n\n\n<p>If you don&#8217;t already have this enabled, you&#8217;ll need to turn it on before installing WSL2. As already stated, WSL2 is a tiny virtual machine, so Windows needs to be prepared for that. If you have this enabled already, skip and go straight to rebooting your PC to make sure you&#8217;re ready to install.<\/p>\n\n\n\n<p>The quickest way to do it is in PowerShell. Open PowerShell as administrator and enter this command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dism.exe \/online \/enable-feature \/featurename:VirtualMachinePlatform \/all \/norestart<\/code><\/pre>\n\n\n\n<h5><span class=\"has-inline-color has-luminous-vivid-orange-color\">Downloading and installing WSL2<\/span><\/h5>\n\n\n\n<ol><li>Download the&nbsp;<a href=\"https:\/\/wslstorestorage.blob.core.windows.net\/wslblob\/wsl_update_x64.msi\">WSL2 Kernel update<\/a>.<\/li><li>Run the installer.<\/li><li>When prompted for elevated permissions, click&nbsp;<strong>yes<\/strong>.<\/li><\/ol>\n\n\n\n<p>Once the installer has done its thing, you&#8217;ll now have WSL2 successfully installed on your PC.<\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4>Setting WSL2 for your Linux distros<\/h4>\n\n\n\n<p>The good thing about WSL2 is that it doesn&#8217;t replace WSL. It just runs alongside it. This means you can run Linux installs with a combination of different versions. You&#8217;re able to set either as default as well as setting a version specifically to each Linux distro you have on your PC.<\/p>\n\n\n\n<p>Let&#8217;s see some of the key commands to use in PowerShell that you&#8217;ll need to know: <\/p>\n\n\n\n<h5><span class=\"has-inline-color has-vivid-cyan-blue-color\">Setting WSL2 as default<\/span><\/h5>\n\n\n\n<p>If you want everything to run on WSL2 as soon as you install it, you can set it as the default version.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wsl --set-default-version 2<\/code><\/pre>\n\n\n\n<h5><span class=\"has-inline-color has-vivid-cyan-blue-color\">Listing installed Linux distros and their WSL version<\/span><\/h5>\n\n\n\n<p>With WSL2 set as default, any Linux installs after that will use it automatically. You can easily check which version of WSL your installed Linux distros are using.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wsl --list --verbose <\/code><\/pre>\n\n\n\n<p><strong>PS<\/strong>: <em>Using the verbose flag will give you the breakdown of which version of WSL is attached to which Linux installation. Without it, you&#8217;ll simply get a list of the versions of Linux you have installed.<\/em><\/p>\n\n\n\n<h5><span class=\"has-inline-color has-vivid-cyan-blue-color\">Changing the version of WSL per Linux installation<\/span><\/h5>\n\n\n\n<p>While setting WSL2 as default will apply it to anything you install afterward. But,\u00a0if you wish to go between versions 1 and 2 or run a mixture on your system, you can do that.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wsl --set-version &lt;distribution name=\"\"> &lt;versionnumber>&lt;\/versionnumber>&lt;\/distribution><\/code><\/pre>\n\n\n\n<p>So, as an example, if you have a Debian installation on WSL that you need to convert to WSL2, you&#8217;d enter<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wsl --set-version debian 2<\/code><\/pre>\n\n\n\n<h5><span class=\"has-inline-color has-vivid-cyan-blue-color\">Launch specific Linux installations in PowerShell<\/span><\/h5>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" width=\"588\" height=\"306\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/08\/image.png\" alt=\"\" class=\"wp-image-2090\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/08\/image.png 588w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2022\/08\/image-300x156.png 300w\" sizes=\"(max-width: 588px) 100vw, 588px\" \/><\/figure><\/div>\n\n\n\n<p>If you only have one version of Linux installed, simply typing<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wsl<\/code><\/pre>\n\n\n\n<p>in PowerShell will launch you into the associated bash shell. But if you have multiple, you can launch a specific distro with this command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wsl -d &lt;distribution name=\"\">&lt;\/distribution>  \/\/ eg: <em>wsl -d debian<\/em><\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Once you&#8217;re done, typing <em>&#8220;exit<\/em>&#8221; will take you back into PowerShell.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>exit<\/code><\/pre>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows Subsystem for Linux (WSL) is a way to run actual Linux inside Windows without the need to set up a virtual machine. The project has seen a ton of support, and WSL2 is the latest and greatest. There is now a new, extremely simplified way to get WSL2 up and running on your Windows [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1721,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[171,502,96,501,580],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1678"}],"collection":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1678"}],"version-history":[{"count":3,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1678\/revisions"}],"predecessor-version":[{"id":2091,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1678\/revisions\/2091"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/1721"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}