WSL Tutorial (2) Error Avoidance Guide

1, package manager problem

There are many people who get a brand new Linux environment and subconsciously execute yum update, apt update && apt upgrade, but I don't recommend you to do this in WSL.

After I installed Ubuntu for the first time, I performed an upgrade, and soon encountered ridiculous problems in subsequent use:

dpkg cannot be used because of dependency problems, but the only solution is to use aptitude to repair dependencies, but aptitude can only be installed through apt, and apt cannot be used because of dpkg problems.

Encountering such a nasty problem, I decided to just delete and reopen, which wasted me a few more hours.

Therefore, I recommend installing aptitude first, so that no matter whether you encounter problems or not, there is such a solution.

2. Port conflict problem

In a previous post, I mentioned being aware of port conflicts.

However, the port conflict of WSL is not like a pure Linux/Windows environment, it will directly report a fatal error and then exit. If WSL uses the same port as Windows, there will be no prompt.

For example: SSH Server For Windows uses port 22, and WSL's SSH uses port 22. This does not conflict, but access to port 22 can only access SSH Server For Windows.

Therefore, when the correct port is accessed but the returned results do not match, you can try to troubleshoot this problem.

3, Systemd problem

WSL is not a full Linux system, so there will be some weird bugs, such as systemctl not working at all.

Therefore, replace systemctl with service. NOTE: The order of parameters differs between the two commands, for example:

Bash
1
2
systemctl start ssh
service ssh start

4. Software download and installation problems

Because the system release version cannot be obtained (or Microsoft is returned), using pip to download some software (for example: supervisor) will report an error, and there is no version corresponding to the release version.

Therefore, it is recommended to install directly using apt:

Bash
1
sudo apt install supervisor

5, Windows firewall problem

By default, using WSL to install software (such as OpenSSH, Python) will pop up Windows Firewall, asking whether to allow the software to use the network.

When using cmd/powershell directly, you can directly click to allow access, but if you use SSH connection, it is often not easy to notice this problem.

Therefore, when the installation software is stuck, you can remotely connect to the desktop to see if there is a Windows Firewall pop-up, or disable it directly.

Note:
My Windows server is a NAT network, so there is no need to worry about security issues;
If there is a public IP and full port, it is not recommended to close the firewall.

WSL Tutorial (2) Error Avoidance Guide

https://blog.tsinbei.com/en/archives/687/

Author
Hsukqi Lee
Posted on

2023-05-18

Edited on

2023-05-18

Licensed under

CC BY-NC-ND 4.0

Comments

Name
Mail
Site
None yet