Windows Subsystem for Linux 2.0 Guide
The Windows Subsystem for Linux (WSL and WSL 2) is a project to provide a Linux shell in Windows 10. With version 2, WSL provides a full blown Linux Virtual Machine with a Linux kernel. Therefore, after installation, you have a full Linux installation BUILT-IN to Windows 10. This makes your Windows PC or laptop on par with a Mac for running Linux. In fact it might be better.
WSL 2 Installation and Docker
To install WSL or WSL 2 you need to follow these steps.
- First you have to have Windows 10 May 2020 Update installed on your system. You can do that here: Windows 10 May 2020 Update Installation
- Next, Install WSL 2. Follow the instructions. If you are missing something, the installer will help you out. As you follow Microsoft's instructions make sure to do these key steps:
- Enable the "Virtual Machine Platform" component.
- You may have to enable Virtualization in your machine's BIOS as well. You will get an error to that effect if you need to.
- Set WSL 2 as your default version of WSL.
- Believe it or not, if you had WSL 1 installed, the system will not switch you to version 2 automatically! Use the following commands to check and set.
- From a Windows Admin Command prompt check default:
wslconfig /l /all
- From a Windows Admin Command prompt set default:
wsl --set-default-version 2
- Install a Linux distro (Ubuntu):
- Go to the Windows Store.
- Search for Ubuntu
- Select the version you want to install
- Select install.
After your launch the app on your desktop, if you are missing anything, you will be prompted on how to fix. After a few minutes and then the Linux subsystem should be installed.
Configure Docker Desktop
Once you have WSL 2 installed, Docker will detect it and then ask you if you would like to switch to WSL as your default VM. Choose yes to switch. After you select the switch, make the following changes to Docker.
- Select Settings -> Resources -> WSL Integration.
- Check Enable Integration...
- Enable your specific distro.
Once you have done that, you can run Docker commands from Windows or from a Linux terminal. Very slick.
Note: Removing an old version of WSL
If you played around with the early beta versions of WSL, you may need to uninstall it. To do that run:
lxrun /uninstall /full
That should get rid of the old version. If that doesn't work, try
lxrun /install to set it up again and then
lxrun /uninstall /full again for the full delete.
Access your Windows 10 Filesystem
- (1) From a Linux terminal, access your C: drive:
- List your home directory:
- (2) From a Linux terminal, open explorer:
- Opens an Explorer Window on Windows desktop.
- Replace '.' with whatever directory you want to open.
- (3) From Windows Explorer using this address to view the Linux file system.
- (4) From the Windows command prompt:
- Use the the
wsl ls -l
wsl ls /home/yourname
wsl sudo apt-get update
Windows 10 WSL Mount External Drive
- (1) Create a mount location in WSL:
- (2) Mount the drive in WSL:
After you do that,
D: should automount every time after that.
Useful WSL Commands
wslconfig /l /all
- List all installed versions
- To get the current version
- This gives you the Linux version you are using
Run Windows Apps
Details can be found on SuperUser
The newest versions allow you to just execute what's in the path:
$ ipconfig.exe | grep IPv4 | cut -d: -f2
$ ls -la | findstr.exe foo.txt
$ cmd.exe /c dir$
WSL 2 Resources