What is WSL?
The Windows Subsystem for Linux (WSL) is a new Windows 10 feature that enables you to run native Linux command-line tools directly on Windows, alongside your traditional Windows desktop and modern store apps.
What are the advantages of WSL?
- WSL requires
fewer resources(CPU, memory, and storage) than a full virtual machine.
- WSL allows you to run
Linux command-line toolsand apps alongside your Windows command-line, desktop and store apps, and to access your Windows files from within Linux.
Bash supportstrengthens the value of the command-line on Windows, allowing PowerShell to leverage other popular technologies.
- WSL shares the
IP addressof Windows.
Which linux distributions have I used?
In the end, I choose to use
Ubuntu in this tutorial.
The reasons are as followed.
- Why not?
Debian: It is very good, but the software is too old.
openSUSE Leap 42: I am not very familiar with it, and need to work with the graphical interface to be more useful.
ArchWSL: Neither installing
atomwill work properly. According to issues, this may be caused by
electron(I'm not sure).
AlpineWSL: It is more suitable for deployment on small equipment, not for development.
WSLwith the largest number of users and the most relevant tutorials is not easy to make mistakes. (But I hate it very much)
ArtixWSL: The derivative version of
Arch Linuxcan get a similar experience without problems.
Recommended open source mirror station:
It is best not to modify the file under
Windows. For details, please see here.
zsh to replace
oh-my-zsh to make the terminal more beautiful.
Please refer to here for the settings of
You may find that the font does not display properly. For the normal display of the font, we also need to do the following.
Control Panelin the Explorer.
Change system locale
win + r， Enter
- Go to
- Find your terminal and add a
REG_DWORDwith the name
CodePageand a value of
- Install Powerline Fonts or Programmer Font or Awesome-Powerline Fonts or Nerd-Fonts.
- Right click on the terminal -
Propertiesto view the current encoding and modify the font.
Port 222 and
PasswordAuthentication yes to
The following operations are only for
Please install the C++ environment first
The complete AUR helper list, I choose
yay for a simple reason - it is written in the
AUR helper does not run under the
root user, so let's create a new user first.
Use zsh/bash instead of windows terminal
I want to execute
windows, the format is as follows.
To execute the
windows program in
bash/zsh, just add
.exe to the end.
It's time to discard
Develop under Winodws
However, I do not recommend this installation method. It is recommended to use nvm.
Using WSLGit, we can use
Git for linux on the Windows side.
Once the download is complete, open
Add a value
WSLGIT_USE_INTERACTIVE_SHELL to the environment variable and set it to
false. This will not call
Shell when used, improving efficiency.
I believe that most people have used tools like
Cygwin. The configuration of WSL is similar. Just add the pipe-program and path-mapping in
Also make sure that the value of
flase , otherwise debugging will not work.
The current official plugin is on the way: Issue #68293.
A viable solution comes from here.
Clion 2018 will be able to support
WSL. If you are using a third-party distribution, please open
%\HOMEPATH%\.CLion2019.1\config\options\wsl.distributions.xml and at the same time open the registry and go to
Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\ and make sure that both
path are the same.
And make sure the following plugins are turned on.
Toolchains to enable the
But unfortunately, if you are using
Artix, this doesn't work.
We can only use WSL as a remote host.
There is no significant difference in efficiency between the two methods, but using
Remote Host will generate temporary files.
The setting of
PyCharm is the same as
There are also two options in
If you use
Remote Host, you need to set the path mappings.
But if your path contains Chinese, this may result in an error, because it uses the
The solution is to set
Develop under WSL
To develop under WSL, you must have a graphical interface. Although the official has never officially supported GUI applications, it has been proven by countless people to be viable (although a lot of mistakes will be reported).
We will use X Window System. It contains
X Server and
The best experience is
X410, which allows me to experience the smoothness of a near-native system. The official description is as follows.
X410 utilizes the source codes from the X.Org open-source project. However, unlike other products from different companies, we've removed the dependencies on Cygwin libraries and streamlined the codes.
Unfortunately, this is a paid software. I recommend to use free trial before you decide whether to buy it.
Free software I recommend
Then you can install the GUI application.
Visual Studio Code is my preference, because I can't find another software that can be both lightness like the Editor and powerful of the IDE.
Then you can start
Chinese Font Installation
After opening, it is found that Chinese displays garbled characters. For this we need to install Chinese fonts.
The installation in
Artix is very simple.
The installation in
Ubuntu is more troublesome. An opportunistic approach is to add
C:\Windows\Fonts to the font directory. However, during use, I found that this would affect the font display under
Windows and even cause the software to crash.
The correct way to do this is to move the font file to the
Ubuntu directory and create a font index. You can refer to here.
settings.json in VSCode for a simple configuration. My configuration is as follows.
The fonts involved are
I mentioned Windows and WSL shared network ports before, so open
http://localhost:8888 directly under Windows.
- C/C++ (optional)
Compilation takes a long time and takes up a lot of space
Cling kernel to
Software such as
Clion can also be used, but I will not introduce it here.
High Level Operation
GUI Software for ssh Connection
X11Forwarding yes to
/etc/ssh/sshd_config to enable
The desktop environment I installed has
dde, of which the first three perform well, but
dde does not work properly in debian and Ubuntu. One possible solution comes from Issue #637.
After the installation is successful, it can be opened in the terminal.
Install the daemon
xrdp that supports Microsoft's Remote Desktop Protocol (RDP).
Win + r run
mstsc to connect
If an error occurs, install one of the backends:
Docker currently only has a client running on WSL and can't run daemons. The mainstream solution on the Internet is to connect to a remote daemon via
Docker CLI, such as
Docker for Windows. But if you still need to open a virtual machine like
hyper-v, it doesn't make sense to do so.
If you insist on using it, you can refer to this.
But now someone has successfully run
Native Docker on WSL, although it is limited in functionality, such as the inability to use
Docker Compose, it is still very exciting.
I only tried and succeeded on
Ubuntu.exe as an administrator.
If you see
Cannot connect to the Docker daemon ... Is the docker daemon running? after opening, please refer to Issue #2291.
- wsl-open: Utility for opening files within the WSL command line in Windows GUI applications.
- wslu: This is a collection of utilities for WSL.
- Ansible-WSL: Provisioning your Windows by Ansible from WSL.
- wsl-terminal: A terminal emulator for WSL,
- LxRunOffline: A full-featured utility for managing WSL.
Here I specifically mention
LxRunOffline. This is definitely a must-have tool for using WSL, the backup feature lets you toss arbitrary and protects systems like Arch.
Q ：The WSL GUI application cannot switch directly to the windows application window after applying full screen.
A: There is no way to solve it, but you can create a new desktop dedicated to
WSL. The shortcut keys for switching between different desktops are
Win + Ctrl + ← and
Win + Ctrl + →.
Q: How do I set the default distribution of WSL?
A : Execute
wslconfig in Powershell. Not only can you set the default distribution, but you can also remove the distribution and change the default user. such as:
Q: Why is WSL's CPU resource usage particularly high?
A: This is largely caused by
Windows Defender. You can turn it off or add the WSL directory to whitelist.
Q: Why are some windows programs not open in bash?
A: By default, only the program in
C:\Windows\System32 can be opened. To open other programs, please write
~/.profile. For example,
export PATH="$PATH:/mnt/c/Program Files/PreSonus/Studio One 4/".
Q: The GUI application is too small for high-resolution screens.
A: The easiest solution is to set the zoom behavior of
X Server under windows. But the fonts tend to be blurry.
The second solution is to execute the following instructions before output:
The third solution is for applications like
Atom developed by
electron, you can directly set
The fourth solution is based on the desktop environment you have installed and the DPI size set in
custom DPI setting.
Q ：How do I change the display language of WSL?
A: This is an example:
WSL makes development under Windows more comfortable. But many problems make it impossible to replace virtual machines or Docker, such as Do not support OpenCL & CUDA, can't use the full
Native Docker and bad
And WSL (Linux) is the thing needs to be tossed, and it takes several failures to find the right one.
Love is the same.
Last modified on 2020-02-26 00:41:21
When reprinting, the original source must be indicated in the form of a link.