WSL (Windows Subsystem for Linux): Hints, How-Tos, Troubleshooting

Table of contents

I. Management of Linux distributions

1. How to enable WSL2 (Windows Subsystem for Linux version 2) and install the latest kernel

2. Short description of Linux distributions in WSL

3. How to install Linux distribution in WSL

4. How to view a list of installed Linux distributions in WSL

5. How to use Linux in WSL

6. How to reset Linux to its initial state in WSL

7. How to uninstall a Linux distribution in WSL

8. How to find out which distributions are running

9. How to shut down all distributions

10. How to reboot or shutdown an individual distribution

11. How to open a Windows file in Linux

12. How to mount removable drives in Windows Subsystem for Linux

13. How to mount network folders, shares

14. Easy File Access in Windows Subsystem for Linux (WSL)

15. Tips for using Debian-based distributions

16. Tips for using openSUSE-based distributions

17. Fedora-based distribution tips

18. How to reset password in WSL

II. Installing and using programs, properties and configuring the system

1. Double Commander (free analogue of Total Commander) in Linux (WSL)

2. How to run a web server in Linux on WSL

3. How to access Linux services in WSL (what is the IP of Linux)

4. How to access Windows services from Linux on WSL

5. How to install an analogue of the Task Manager in Linux on WSL

6. How to view open ports in Linux on WSL

7. How to run MySQL DBMS on Linux on WSL

8. Does Linux in WSL support graphical user interface

III. Troubleshooting WSL

1. Error “WslRegisterDistribution failed with error: 0x80370102”

2. Error “Address already in use … make_sock: could not bind to address”

3. Why Linux does not see Wi-Fi adapters in WSL

4. Can Linux in WSL use graphics cards to perform computation

5. Error in WSL (Kali Linux, Ubuntu) “sleep: cannot read realtime clock: Invalid argument”

6. Error “unable to connect to socket: Connection failed, the destination computer rejected the connection request. (10061)”

7. Error “E: Release file for http://http.kali.org/kali/dists/kali-rolling/InRelease is not valid yet (invalid for another 2h 43min 57s). Updates for this repository will not be applied”


Miloserdov.org is preparing a series of articles on using Kali Linux in the Windows Subsystem for Linux (WSL). In my opinion, these instructions are very interesting for both WSL beginners and Kali Linux beginners. These instructions do not just master the terminal and basic commands, but examples of using the best tools right in Windows without the need to install another operating system or Python, Ruby, Perl and others.

WSL technology allows you to quickly access many Linux tools while spending a minimum amount of time setting up a working environment.

However, to use the Linux and Kali Linux tools effectively, you need to be familiar with them and know the syntax for launching them (more on that in the next part). But it is equally important to feel confident with Linux in WSL – this is what this section is about. It provides step-by-step instructions for using WSL, provides tips and tricks for basic steps, and describes solutions to some problems.

This list of hints will continue to grow. If you have a question about WSL, then ask it in the comments.


I. Management of Linux distributions

How to enable WSL2 (Windows Subsystem for Linux version 2) and install the latest kernel

Microsoft has worked with Canonical to offer a complete Ubuntu-based Bash shell environment that runs on top of that subsystem, and it is now possible to run full Linux distributions. Technically it's not Linux at all. Linux is the base operating system kernel that is not available here. Instead, it allows you to run the Bash shell and the same binaries that you normally run on Ubuntu Linux. Free software proponents often argue that the average Linux operating system should be called “GNU/Linux” because there are actually many GNU programs running on the Linux kernel. The Bash shell you get is actually all these GNU utilities and other software.

This feature was originally called “Bash on Ubuntu on Windows”, but it also allowed you to run Zsh and other command line shells. It now supports other Linux distributions as well. You can choose openSUSE Leap or SUSE Enterprise Server, Fedora or Kali Linux over Ubuntu.

There are some limitations here. It does not yet support background server software and does not officially work with graphical Linux desktop applications. Not all command line applications work as well, as the feature is not perfect.

WSL2 is disabled by default on Windows. To enable it, you can use the graphical interface or the command line. To enable WSL2 in the command line, press Win+x and select “Windows PowerShell (administrator)” in the menu that opens:

It's important to open PowerShell with elevated privileges.

Run the command:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Wait for the download and execution to finish.

Restart your computer by pressing Enter.

Now open PowerShell again as administrator and run:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Restart your computer again.

Download and install the latest WSL2 Linux Kernel from here: https://aka.ms/wsl2kernel (direct link).

Open PowerShell again as administrator and run:

wsl --set-default-version 2

If you already have a distribution kit (for example, Kali Linux) installed in WSL1, then run the command to update:

wsl --set-version kali-linux 2

Short description of Linux distributions in WSL

Debian

Debian is popular as a distribution, for example, for servers, and as a base for other distributions. For example, Ubuntu, Kali Linux, Linux Mint are based on Debian (there is an LMDE version that is based directly on Debian, and also a “classic” version that is based on Ubuntu, which in turn is also based on Debian).

That is, Debian and derivatives are very popular.

You will be able to use the complete Debian command line environment containing the full current stable environment.

Kali Linux

Kali Linux is the most popular distribution for information security professionals, digital forensics, hackers and advanced users. You can install and use many specialized tools in your native Linux environment. For Kali Linux, software has been developed to simplify the launch of the graphical interface (see the article “How to install Kali Linux with Win-KeX (GUI) in WSL2 (Windows Subsystem for Linux)”, as well as this particular distribution was taken for instructions on Miloserdov.org, therefore you will find many detailed manuals for it, for this reason Kali Linux is recommended.

SUSE Linux Enterprise Server

SUSE Linux Enterprise Server is a multimodal operating system that paves the way for IT transformation in the software age. A modern modular OS helps to simplify multimodal IT, makes traditional IT infrastructure efficient, and provides an attractive platform for developers. As a result, you can easily deploy and migrate business-critical workloads to on-premises and public clouds. SUSE Linux Enterprise Server 15 SP1, with its multimodal design, helps organizations transform their IT landscape by combining traditional and software-defined infrastructure.

Ubuntu

In WSL, the Ubuntu distribution also lacks a graphical interface (as all other distributions have by default), so it cannot be called more user-friendly. Based on Debian.

Fedora

They promise to add, but not yet.

How to install Linux distribution in WSL

After you've enabled WSL2 as shown in the previous section, open the Microsoft Store from the Start menu.

And search for “Linux” in the store. Select Debian or another Linux distribution from the Store app.

You will see a list of all Linux distributions currently available in the Windows Store. This includes Debian, Kali Linux, Ubuntu, openSUSE Leap and openSUSE Enterprise with the promise of Fedora coming soon.

To install a Linux distribution, click it, and then click the Get or Install button to install it like any other Store app.

If you don't know which Linux environment to install, we recommend Debian. This is a popular Linux distribution that can be used for a wide variety of purposes. Or choose another Linux system if you have more specific needs.

You can also install multiple Linux distributions, each with their own unique shortcuts. You can even run several different Linux distributions at the same time in different windows.

How to view a list of installed Linux distributions in WSL

To list all distributions, use the following command:

wsl --list --all

The --all option is needed so that all distributions are included in the list, including those that are currently being installed or removed.

The exact same list can be obtained using the command:

wslconfig /l

You can see the “default” mark, it indicates the distribution that will be launched if you run the command in the Windows command line:

bash

If you do not need to display information about which of the systems is selected by default (that is, it starts when executed in the bash command line), then use the following command:

wsl --list --quiet

There are two ways to list the Linux distributions that are currently running.

The first method dumps all Linux to WSL and marks the currently running:

wsl --list -v

The value “Running” in the “STATE” field means that this distribution is running.

And the second command shows only running ones, without displaying inactive ones at all:

wsl --list --running

How to use Linux in WSL

To open the Linux environment you have installed, simply open the start menu and find the distribution you installed. For example, if you've installed Kali Linux, launch the Kali Linux shortcut.

You can pin this application shortcut to the Start menu, taskbar, or desktop for easy access.

When you start your Linux environment for the first time, you will be prompted for a UNIX username and password. They do not need to be the same as your Windows username and password, but will be used in a Linux environment.

For example, if you enter “alex” and “miloserdov” as credentials, your Linux username will be “alex” and the password you use in Linux will be “miloserdov” – regardless of your Windows username and his password.

You can start your installed Linux environment by running wsl command. If you have multiple Linux distributions installed, you can choose the default Linux environment launched by this command.

If you have Kali Linux installed, you can also run the kali command to install it. For openSUSE Leap 15 SP1, use opensuse-15-sp1. For SUSE Linux Enterprise Server 15 SP1, use SLES-15-SP1. These commands are listed on each Linux distribution's Windows Store page.

You can still start the default Linux environment by running bash, but Microsoft claims this is deprecated. This means that the bash command may stop working in the future.

If you have experience using the Bash shell on Linux, Mac OS X, or other platforms, you will be right at home.

On Kali Linux and Ubuntu, you need to prefix the command with the sudo prefix to run it as root. The “root” user on UNIX platforms has full access to the system as the “Administrator” user on Windows. Your Windows filesystem under the Bash shell is /mnt/c.

Another important feature of Linux distributions launched in this way is that you can execute Windows commands right in the Linux console.

Use the same Linux terminal commands that you use on that operating system. If you are used to the standard Windows command line with its DOS commands, here are some basic commands that Bash and Windows have in common:

  • Change directory: cd in Bash, cd or chdir in DOS
  • List directory contents: ls in Bash, dir in DOS
  • Moving or renaming a file: mv in Bash, move and rename in DOS
  • Copy file: cp in Bash, copy in DOS
  • Delete file: rm in Bash, del or erase in DOS
  • Create directory: mkdir in Bash, mkdir in DOS
  • Use a text editor: vi or nano in Bash, edit in DOS

It is important to remember that, unlike Windows, the Bash shell and its environment that mimics Linux are case-sensitive. In other words, “File.txt” with a capital letter is different from “file.txt” without a capital letter.

You will need to use the apt command to install and update your Debian, Kali Linux, Ubuntu environment software. Remember to prefix these commands with the sudo prefix so that they run as root, the Linux equivalent of Administrator. Here are the apt commands you need to know:

Download updated information on available packages:

sudo apt update

Install the application package (replace “PACKAGE-NAME” with an actual package name):

sudo apt install PACKAGE-NAME

Removing an application package (replace “PACKAGE-NAME” with an actual package name):

sudo apt remove PACKAGE-NAME

Search for available packages (replace WORD with the word by which you want to search for packages in names and descriptions):

sudo apt search WORD

Download and install the latest versions of installed packages:

sudo apt full-upgrade

If you installed a SUSE Linux distribution, you can use the zypper command to install the software instead.

Once you've downloaded and installed the app, you can enter its name in the prompt and then press Enter to launch it. For more information, see the documentation for your specific application.

The software installed in the Bash shell is limited to the Bash shell. You can access these programs from the command line, PowerShell, or anywhere else on Windows, but only if you run a command like

bash -c COMMAND

How to reset Linux to its initial state in WSL

To reset a distribution to its initial state, you need to know its name – this name does not always correspond to the command that it is launched with.

To see the name of the distribution for use in a command, run:

wsl --list --all

To reset the distribution to its original state (all settings and all saved files will be deleted), run a command like this:

wslconfig /u DISTRIBUTION

For example:

wslconfig /u SLES-15-SP1

How to uninstall a Linux distribution in WSL

To uninstall a Linux distribution, you need to know its name – this name does not always correspond to the command with which it is launched.

To see the name of the distribution for use in a command, run:

wsl --list --all

To completely remove the distribution kit and free up disk space, run a command like this:

wslconfig /t DISTRIBUTION

For example:

wslconfig /t Debian

How to find out which distributions are running

You can view running distributions with two commands.

The first method dumps all Linux of WSL and marks the currently running:

wsl --list -v

The value “Running” in the “STATE” field means that this distribution is running.

And the second command shows only running ones, without displaying inactive ones at all:

wsl --list --running

How to shut down all distributions

Previously, to exit Linux running using WSL (Windows Subsystem for Linux), it was enough to close the terminal. In recent versions, when you exit the Linux console (for example, if you press Ctrl+d or close the terminal), the Linux distribution will continue to work in the background.

To turn off all running Linux at once, run the command:

wsl --shutdown

How to reboot or shutdown an individual distribution

You can stop not all systems, but certain ones, for this use a command like:

wsl -t DISTRIBUTION

For example, I want to shutdown Kali Linux – the name of this distribution to manage is kali-linux, then the command is as follows:

wsl -t kali-linux

Please note that the distribution name is not the same as the launch command. For example, for Kali Linux, the launch command is kali, and the distribution name is kali-linux. The commands above (wsl --list -v) show the name of the distribution you can use to shutdown it.

How to open a Windows file in Linux

All computer disks are mounted in the /mnt/ folder. For example, drive C:/ is mounted on the /mnt/c path.

To view the contents of the C:/ drive, run the command:

ls -l /mnt/c

From here you can access any user or system file.

For example, I want to view the contents of a file named 123.reg, which is located in the C:\Users\MiAl\Documents\ folder, that is, on Windows, the path to this file is C:\Users\MiAl\Documents\123.reg. Then, in Linux, this file will be available at /mnt/c/Users/MiAl/Documents/123.reg:

cat /mnt/c/Users/MiAl/Documents/123.reg

Note that on Linux:

  • slashes are used, not backslashes like in Windows
  • the case of letters matters. That is, file.txt and File.txt are completely different things.

If you use a graphical interface in Linux (how to install and run it in Kali Linux is described in this article), then you can install Double Commander (described below) and conveniently move and copy files between the two operating systems:

How to mount removable drives in Windows Subsystem for Linux

The Windows Subsystem for Linux automatically mounts NTFS-formatted persistent drives in the Linux distribution. That is, if you have an internal C: drive and a D: drive, then in Linux you will see them in /mnt/c and /mnt/d.

DrvFs now allows you to mount external drives such as USB sticks, CDs and DVDs. These devices must use the Windows file system such as NTFS, ReFS, or FAT. You still cannot mount devices formatted with Linux filesystem, such as ext3 or ext4.

Like internal drives, these external drives will remain accessible in Windows once they are connected in a Linux environment. And once they are mounted, as shown in this article, they will be simultaneously available on Windows and Linux.

Let's say you have an external media M: it is either a USB stick or an optical drive. To mount it, you must run the following commands:

sudo mkdir /mnt/m
sudo mount -t drvfs M: /mnt/m

Of course, you don't have to mount the disk at /mnt/m. You may mount it anywhere you like. Just replace both instances of the /mnt/m line in the above commands with the path you want.

Let's see from Linux the contents of the USB disk that we just mounted:

ls -l /mnt/m

To later unmount the disk and safely remove it, run the standard umount command:

sudo umount /mnt/m/

There are some limitations when working with an external device formatted in the FAT file system or any network file system. The filesystem is not case-sensitive and you cannot create symbolic or hard links on it.

How to mount network folders, shares

You can also mount network locations (folders, shares). Any network location accessible from Windows can be mounted from the Linux shell.

Network locations can be mounted in one of two ways. If you map a network drive to a drive letter, you can map it using the same options as above. This will give you the ability to easily log into the network share and enter your credentials in File Explorer. For example, if your network drive is mapped with the letter F:, you can run the following commands to mount it:

sudo mkdir /mnt/f
sudo mount -t drvfs F: /mnt/f

You can also specify a drive using its UNC (Universal Naming Convention) path. For example, if the path to the network share is \\SERVER\FOLDER, you must run the following command. Again, use any mount point instead of /mnt/FOLDER.

sudo mkdir /mnt/FOLDER
sudo mount -t '\\SERVER\FOLDER' /mnt/FOLDER

The Windows Subsystem for Linux provides no way to specify the credentials you want to use. You can provide credentials by navigating to a folder in Windows Explorer, entering them through the Credential Manager, or using the net use command.

The net use command can be run from a Linux environment because the Windows Subsystem for Linux allows you to run Windows software from the Linux command line. Just run the command like this:

net.exe use

For example, the following command will connect to \\SERVER\FOLDER with username Bob and password LetMeIn and assign it the drive letter F:. Here is the command you should run:

net.exe use f: \\SERVER\FOLDER /user:Bob LetMeIn

After you connect once, Windows will remember this username and password and will automatically use them even if you use the mount command in a Linux environment.

To disable the network location, you can use the standard umount command again:

sudo umount /mnt/FOLDER

DrvFs inaccurately sets Linux permissions when connecting NAS. Instead, all files on the network filesystem have Full Control permission (0777), and you can see if you have access to a file just by trying to open it. The filesystem will also be case-insensitive and you won't be able to create symbolic links to them.

Easy File Access in Windows Subsystem for Linux (WSL)

You can open an explorer window directly in the current directory from a Linux shell environment. Just enter the following command into the Bash shell:

explorer.exe .

From here you can work with files normally. Use drag and drop, copy and paste them, or even open them directly in Windows applications to modify them.

Microsoft may change how this works in the future. But for now, you can also enter the following path into the explorer window to access the files of the Linux distribution:

\\wsl$\<running-distribution-name>\

In other words, if you are using Kali Linux, you must enter:

\\wsl$\Kali-Linux\

This of course also works from the command line. In PowerShell or command line

cd \\wsl$\Kali-Linux\

Tips for using Debian-based distributions

Regular system updates

Updates fix bugs in the system and bring new functions. To perform a full update, run the command:

sudo apt update && sudo apt full-upgrade -y

Regular system cleaning

From time to time, it is recommended to run commands to remove packages that were automatically installed (since they were dependencies of other programs), but are no longer needed.

To do this, use the command:

sudo apt autoremove -y

Its use is safe and shouldn't lead to problems.

With each software update, the package files are downloaded to the cache. After the update, the downloaded files (you can call them installation files) are not deleted, and gradually the cache grows to large sizes. This is done intentionally with the idea that if after the next update you find that the new package has problems, and the old version is no longer available in the online repository, then you can roll back to the old version by installing it from a file saved in the cache.

For rolling distributions, the cache grows very quickly, and if you are not qualified to rollback to the old version, the installation package of which is stored in the cache, then for you these hundreds of megabytes or even several gigabytes is wasted hard disk space. Therefore, from time to time you can execute the commands

sudo apt autoclean -y

and

sudo apt clean -y

clean – delete downloaded archive files

clean cleans out the received package files from the local repository. It removes everything except the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/.

autoclean – delete old downloaded archive files

Like clean, autoclean cleans out the downloaded package files from the local repository. The only difference is that it only removes package files that can no longer be downloaded and are largely useless.

This allows the cache to be maintained for a long period without growing too much. The APT::Clean-Installed configuration option will not allow the installation files of the packages that are currently installed to be deleted.

Fixing package and dependency installation errors

The following command is not directly related to cleaning, but helps maintain system health.

sudo apt install -f -y

The -f, --fix-broken option fixes, tries to bring the system back to normal with broken dependencies. This option, when used with install/remove, can skip any packages to allow APT to find a likely solution. If packages are listed, this should completely fix the problem. This option is sometimes needed when starting APT for the first time; APT itself does not allow packages with broken dependencies to exist on the system. It is possible that the system's dependency structure could be so broken that manual intervention would be required (which usually means using dpkg --remove to remove some offending packages). Using this option in conjunction with -m may cause an error in some situations. Item in the configuration file: APT::Get::Fix-Broken.

Search for software packages

Search for available packages (replace WORD with the word by which you want to search for packages in names and descriptions):

sudo apt search WORD

Installing and removing packages

Install the application package (replace “PACKAGE-NAME” with the package name):

sudo apt install PACKAGE-NAME

Removing an application package (replace "PACKAGE-NAME" with the package name):

sudo apt remove PACKAGE-NAME

Tips for using openSUSE-based distributions

TBD

Fedora-based distribution tips

TBD

How to reset password in WSL

We need to find out the name of the executable file, for this run the following commands:

cmd
cd c:\users\%USERNAME%\AppData\Local\Microsoft\WindowsApps
dir

In this screenshot, this is kali.exe.

And on this test machine, we installed Ubuntu 20.04, and obviously we need the ubuntu2004.exe file.

We'll start an Ubuntu session and log in as the root user instead of the user account you created when you installed the Linux distribution.

ubuntu2004 config --default-user root

The Ubuntu session is running and we see the command line in the terminal window. The prompt is in white text, and the last character is a hash “#”, not a dollar sign “$”. This tells us that the user is root and not a regular user. The prompt also contains the word “root”.

We can double check with the following command:

whoami

So we are definitely logged in as root. We can change the default user password. The passwd command will ask you for a new password and then ask you to confirm it. None of them will echo on the screen. The password we are changing belongs to user dave.

passwd dave

Make sure you remember the new password. We will log out of the Ubuntu session and return to the Windows Command Prompt.

exit

To verify our new password, we need to start a new Ubuntu session with a regular user account.

ubuntu2004 config --default-user dave

The session begins and we are logged in as a regular user with our usual colored command line.

To prove that our password has been changed, we'll run the command with sudo. The command we use doesn't matter, what matters is that we use sudo. We'll use the ps command to list some of the processes.

sudo ps -e

You will be prompted for the password that you created when you used the passwd command as root. The password should be accepted and the command should be run for you.

II. Installing and using programs, properties and configuring the system

In this section, only common programs will be touched upon, specialized tools will be discussed in separate instructions.

The installation of programs is illustrated using the example of a Debian distribution and derivatives. In other distributions, packages must be named the same.

Double Commander (free analogue of Total Commander) in Linux (WSL)

To install the Double Commander dual window file manager, which supports Total Commander functions and plugins, run the following command:

sudo apt install doublecmd-gtk

Double Commander is cross-platform, meaning it runs on Windows and Linux. It is recommended to install it instead of the pirated Total Commander.

How to run a web server in Linux on WSL

Although no server background services are officially supported, I was able to successfully run Apache web server on Kali Linux (should work on all Debian derivatives).

To start the web server, install the apache2 and php packages:

sudo apt update
sudo apt install apache2 php

Run the command to start the web server service:

sudo /usr/sbin/apache2ctl start

The web server is running, you can check this by looking at the open ports:

ss -tulpn

On Kali Linux and other Debian derivatives, the web server files are located in the /var/www/html/ folder.

How to access Linux services in WSL (what is the IP of Linux)

A virtual Ethernet network is created for Linux distributions. Thanks to this network, it is possible to access from Windows to Linux and also vice versa.

To find the Linux IP address, run the command:

ip a

The screenshot shows that the Linux IP address is 172.26.173.37. In the previous step, we launched a web server – let's try to open a page from a web server in Linux in a web browser from Windows:

We see “Apache2 Debian Default Page”, which is the default page of the Apache web server on Debian.

It means that

  1. The web server actually works
  2. We can access Linux network services from Windows

What remained unclear to me is that all running distributions have the same IP address. Moreover, if you start the service (open a port) on one of the distributions, then the same port will be open on all the others. Therefore, for example, you cannot run a web server simultaneously on two or more distributions… All distributions in WSL share one network interface for all.

How to access Windows services from Linux on WSL

Let's consider another option – a server (web, FTP, etc.) or a network service is running on Windows, can I connect to it from Linux on WSL? Can! We need to know the Windows IP address in the virtual network created for WSL.

From Linux, this IP address can be viewed with the command:

ip route show default

Windows IP address is 172.26.160.1.

In Windows itself, you can also see this IP, and in at least two ways.

In a terminal using the command:

ipconfig

In the graphical interface, in the Task Manager on the “Performance” tab:

Then use this IP address to connect to your web server, FTP or any other Windows service from Linux on WSL.

How to install an analogue of the Task Manager in Linux on WSL

If you are only using the command line interface, then run the top command, which is usually already preinstalled:

top

Some users prefer an analogue of this utility called htop. It's usually not there by default, so start by installing:

sudo apt install htop

To run, run:

htop

If you are using a graphical desktop environment, then you can install a program very similar to the Task Manager called System Monitor, to do this, run the command:

sudo apt install gnome-system-monitor

Then launch System Monitor from the menu or console:

gnome-system-monitor

How to view open ports in Linux on WSL

You can see the open ports with the command:

ss -tulpn

How to run MySQL DBMS on Linux on WSL

For a fully functional web server, you need a DBMS, for example, MySQL or MariaDB.

In theory, they should be started by a command of the form:

sudo /usr/sbin/mysqld

But currently MySQL/MariaDB doesn't work in WSL yet.

Does Linux in WSL support graphical user interface

Not officially supported, but there are options for installing and connecting to it. An example and more details can be found in the article “How to install Kali Linux with Win-KeX (GUI) in WSL2 (Windows Subsystem for Linux)”.


III. Troubleshooting WSL

Error “WslRegisterDistribution failed with error: 0x80370102”

If you get an error while trying to run the distribution:

WslRegisterDistribution failed with error: 0x80370102
Error: 0x80370102

then its reason is that the central processor does not support virtualization. The source of the problem can be different:

  • you disabled virtualization in BIOS
  • your processor does not support virtualization at all
  • you run Windows in a virtual machine already (regardless of the model, processors there do not support virtualization).

Error “Address already in use … make_sock: could not bind to address”

When starting a network service that binds (opens port to listen), such as the Apache web server:

sudo /usr/sbin/apache2ctl start

An error similar to the following may occur:

(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

Its essence is that the specified port (80 in this case) is already in use by another process.

The error can occur even in a distribution in which network services are not running. The fact is that at the moment all Linux distributions have one common network (virtual) card. Therefore, if you run a web server or other service on one distribution, you cannot start it on another until you stop the first instance.

Why Linux does not see Wi-Fi adapters in WSL

Linux in WSL does not have direct access to the computer hardware. For this reason, it is not possible to use Wi-Fi adapters, even USB Wi-Fi adapters, in WSL.

Can Linux in WSL use graphics cards to perform computation

At the moment, Linux in WSL cannot use GPUs, but they promise to add this feature later.

Error in WSL (Kali Linux, Ubuntu) “sleep: cannot read realtime clock: Invalid argument”

An error can occur when trying to install the program:

sudo apt install PACKAGE

Or when updating packages and system:

sudo apt update && sudo apt full-upgrade -y

These commands will output something like the following:

E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Running

sudo apt --fix-broken install

will lead to other errors:

sleep: cannot read realtime clock: Invalid argument
dpkg: error processing package libc6:amd64 (--configure):
installed libc6:amd64 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
libc6:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

And so on.

To fix, run the following commands:

sudo -i
sudo mv /bin/sleep /bin/sleep~;
touch /bin/sleep;
chmod +x /bin/sleep

Then try again

sudo apt --fix-broken install

And then install the required package or update the system as usual.

 Error “unable to connect to socket: Connection failed, the destination computer rejected the connection request. (10061)”

When using the kex command in Kali Linux (Win-KeX), an error may occur:

unable to connect to socket: Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение. (10061)

The command line outputs:

TigerVNC Viewer 32-bit v1.10.80
Built on: 2020-06-15 22:33
Copyright (C) 1999-2020 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.

Fri Sep 11 06:41:39 2020
 DecodeManager: Detected 12 CPU core(s)
 DecodeManager: Creating 4 decoder thread(s)

Fri Sep 11 06:41:41 2020
 CConn:       unable to connect to socket: Connection
              is not established because the destination
              computer rejected the connection 
              request. (10061)

To fix this error press Ctrl+c.

Then enter the command

kex stop

This command might output something like the following:

Killing Win-KeX process ID 1618... which was already dead
Cleaning stale pidfile '/home/mial/.vnc/HackWare-MiAl.localdomain:1.pid'!
Cleaning stale x11 lock '/tmp/.X1-lock'!
Cleaning stale x11 lock '/tmp/.X11-unix/X1'!

Try opening the GUI again:

kex

This time everything should work:

The reason for the error is not completely clear – perhaps it is a failed start of the VNC server or the Win-KeX process, this is indicated by the line “Win-KeX process ID 1618 … which was already dead”.

With the kex stop command, we forcibly stop Win-KeX, which works normally the next time it starts.

Error “E: Release file for http://http.kali.org/kali/dists/kali-rolling/InRelease is not valid yet (invalid for another 2h 43min 57s). Updates for this repository will not be applied”

When trying to update Kali Linux, I encountered the error:

Its essence is that the release file for the repository is not yet valid and, therefore, updating from this repository is impossible.

This can happen due to incorrect digital signature of the repository or incorrect time.

I ran into this error in WSL2 (Windows Subsystem for Linux), but theoretically it could appear on a regular Kali Linux distribution and Dockers too.

This problem is caused by the wrong timezone setting in Windows, as a result of which the Linux distribution in WSL also receives the wrong time.

The distribution kit in WSL receives the time when it starts, that is, even if you subsequently corrected the time in Windows, in previously launched WSL distributions the time will still be incorrect and the error will persist.

To fix, as mentioned, you start by setting the correct time and correct time zone on the Windows host machine.

Then you need to use one of the following methods:

1. You can shutdown and restart all Linux distributions by running the command:

wsl --shutdown

2. Another way, inside the Linux distribution, run the command:

sudo hwclock --hctosys

This command gets the latest time from the RTC of your Windows machine and uses it to set the system time on Linux.

Try updating again:

sudo apt update && sudo apt full-upgrade -y

As you can see from the screenshot, this time the update started without errors:

Recommended for you:

2 Comments to WSL (Windows Subsystem for Linux): Hints, How-Tos, Troubleshooting

  1. esi says:

    How can I install/enable WSL2 on pirated windows

    • Alex says:

      Hello! It seems there is no difference between properly licensed and pirated Windows.

      But I urge do not use any pirated software if you concern about information security and safety of your files, passwords and all other digital stuff.

      The dozens of botnets with millions computers make these concerns reasonable.

Leave a Reply to Alex Cancel reply

Your email address will not be published. Required fields are marked *