How does Windows Subsystem for Linux (WSL) work

211 views

How can I run Linux commands inside a windows operating system?

In: 1

2 Answers

Anonymous 0 Comments

Linux programs expect to have a set of libraries available that perform Linux system services.

To the program, “a library” is just the way Linux agrees to organize code in a file so another program can call it. Programs are not usually picky, and if two files have different code organized the right way, a program will run either of them when it asks for a certain library.

So the WSL, greatly oversimplified, is a set of libraries MS wrote that look like the Linux system libraries as far as the programs are concerned. But the code inside those libraries do things the Windows way, taking great care that when they report their results to the program they convert the Windows answer to some questions to the Linux answer to that question.

It took so long because that was a huge effort, there were thousands of bits of code to get right. It’s an easy task to describe, but very difficult to achieve.

Anonymous 0 Comments

There is a WSL kernel running on top of the Windows kernel.

It acts as a translation layer that translates linux system calls to windows system calls.

WSL2 has a linux kernel running next to the windows kernel. With a tiny utility virtual machine.