With the Windows Subsystem for Linux (WSL & WSL2), Microsoft has brought a full Linux environment to Windows. I’ll show some tips and tricks, so software development on the WSL2 becomes even more fun! 💻
In my list, I focus on Ubuntu/Debian as Linux distribution. Most of the advice should be tranferrable to any distribution.
The first thing to understand is that your Windows host system and your WSL Linux guest system have different file systems.
You can access each file system from both systems. A note of warning: Cross-system file access is extremely slow, especially in WSL2.1
Accessing the WSL file system from Windows: The WSL file system is located under the path “
\\wsl$”. Easiest is to enter this path in the Windows file explorer address bar and press enter. For the future, it is pretty handy to add this path as a file explorer shortcut.
Accessing the Windows file system from WSL: The Windows file system is located under “
/mnt/”. So, the C partition has the path “
Neat trick: You can open the Windows file explorer tool from a WSL terminal! Just enter the command “
explorer.exe .”, and your current folder will be opened in the file explorer. This saves a lot of navigating around! 🤩
Linux File Permissions
When you access the Windows file system from Linux, you will notice after a time that the file permissions are weird (they are very open) and you cannot use
chown on them. I noticed this especially when working with Git repositories located in the Windows file system.
This is because Windows applies the current Windows user permissions to all files. To modify the permissions and ownership individually, edit the file “
/etc/wsl.conf” (creeate the file if itdoes not exist) and add these two lines:
If you already have an automount section, just add the second line to this section.
After a WSL restart (execute “
wsl --shutdown” from PowerShell or CMD), you should be able to set permissions and ownerships.
Best is to use an IDE that has WSL support. Otherwise, as your project files are located in the WSL file system, but your IDE is installed in Windows, you will run into cross file system performance issues soon.
In my experience, VS Code with its Remote Development Extension Pack has the best WSL support, and you pretty much don’t notice that you are working on a different file system. JetBrains’ IDEs also work pretty well.
If you are using Docker, easiest is to use Docker Desktop with its WSL2 backend. If you can’t/don’t want to use Docker Desktop, you can pretty much directly install the Linux version. I have blogged about it here: Install Docker in WSL2 (Ubuntu) without Docker Desktop
Have a happy time using Linux on Windows! 🐧🪟
Cross file system access was much faster in WSL1. But between WSL1 and WSL2, the approach was changed: WSL1 takes Linux system calls and translates them into Windows NT kernel calls. This results in good cross-system performance, but not all Linux system calls could be supported. WSL2 uses virtualization - it uses a lightweight VM with an optimized Linux kernel. This increases Linux performance & lets WSL2 support all Linux system calls. ↩︎
- Get Total Directory Size via Command Line
- Changing DNS server for Huawei LTE router
- Notes on Job & Career Development
- Adding full-text search to a static site (= no backend needed)
- Generating a random string on Linux & macOS
- Caddy web server: Why use it? How to use it?
- Tailwind CSS: A Primer
- Versicherungen: Learnings
- Screen Recording on macOS (without any extra tools)
- Install Docker in WSL2 (Ubuntu) without Docker Desktop