Let's use WSL

WSL (Windows Subsystem for Linux) has been installed on the computer for a long time. If anyone has not installed it, you can read this article, at least know the general idea, and know how to do it if you find it useful.

Introduction

WSL is simply a subsystem that allows you to run Linux programs on Windows. What is a subsystem? Paste a picture:

In fact, we have been using the subsystem, which is the Windows subsystem, which provides a series of interfaces that our Windows applications need. The application can run normally, and now there is an additional WSL, which can convert the calls of Linux programs to various system interfaces into calls to the Windows kernel. Therefore, Linux applications can run in the Windows system. Cool! Conversely, can I make a similar thing in Linux system to run Windows programs? In fact, this thing has been around for a long time, called "Wine", go check it yourself.

Is it a virtual machine?

No, it's a subsystem, Linux programs are side by side with native Windows programs, as you can see from the picture above. The virtual machines are isolated from each other, but the subsystems are not isolated. The file system can access each other and share IP addresses. Moreover, the resource consumption of WSL is much smaller than that of virtual machines, and you will not feel that the system slows down when you install it.

Is it real Linux?

What is the definition of Linux? Is Mac OS X Linux? In fact, I personally don't think it is necessary to worry too much about this problem. WSL obviously uses the Windows kernel, (you can use the uname command to view it), but it has a fairly complete Linux system function and can run almost all Linux programs. It must be *real * Linux, you can even choose a different distribution, uh, the so-called distribution is Ubuntu, CentOS, Fedora and the like.

What do you use it for?

Of course, you can use all kinds of powerful tools on Linux, such as ssh, you don't have to worry about where to go to the next Windows version, all kinds of powerful X tools, what you want, just apt-get and get it , those cool shell commands under Linux are all at your disposal now, and of course you can easily build a web server with a few commands. All in all, it is better than the command line interface of Windows (some people call it DOS now) Gao did not know where to go.

Are there any restrictions?

Yes, since it uses the Windows kernel, my first reaction was that Docker, which relies on the CGroups function of the Linux kernel, should be useless... But I checked later and found that someone has successfully installed and used it, which surprised me. Specifically The steps are a little complicated, and I haven't had time to look at it yet, so you can search by yourself. In addition, Microsoft officially said that WSL is not suitable for use as a server in the production environment, because it was not designed for this, and the server in the production environment should still use a Linux virtual machine.

How to get started?

Ha, do you want to act? I won't write a set of "tutorials" anymore, and there are a lot of searches on the Internet. But I still recommend it: you search for "WSL Guideline" in the app store, this is a good guide, look at this.

Which distribution to choose?

The following distributions are currently available in the app store:

The Linux distribution I use for work is CentOS7.4, which is not available here. There are guides online on how to install any distribution of Linux, but I was too lazy to toss, so I chose Ubuntu directly. The difference between the software packages, just get used to the following, for example, I am used to using yum, Ubuntu is not installed by default, just install it with apt-get, and the same is true for others.

How to communicate with Windows?

Linux access to Windows is very simple, the C drive of Windows will be linked to "/mnt/c", and similarly there are "/mnt/d" and "/mnt/e", etc., the files in this can be directly read and written; It's a bit troublesome to come over. The Linux files are actually in this directory:

%LOCALAPPDATA%\Packages\{Linux distribution}\LocalState\rootfs

(The Linux distribution here is CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc)

This directory is hidden deeply. Secondly, if you try to copy files to this directory directly in Windows, Linux will not be able to read them, so if you want to share files, you should use the Windows file system.

What is the root password?

The default user is your own windows account, the root user has no password by default, you can change it: sudo passwd

Next step

In fact, I don't know either, I just know it's easy to use, and I'm not good at how cool it is to play. For example, the graphical interface, this is very cool, but I think the graphical interface is still better than Windows, and the Windows graphical interface is no better than KDE/Gnome. Then again, this is not part of our work, so you can figure it out for yourself.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325125479&siteId=291194637