cygwin and WSL

Since the early days of the NT operating system, Windows provided a Posix subsystem, even if it was not complete or known to most users.

Microsoft changed multiple times the implementation and name of this subsystem. The first version was named Microsoft POSIX subsystem, with Windows 2000. With Windows 8 we got the Windows Services for UNIX, and now, with Windows 10, we have the Windows Subsystem for Linux.

I have no experience with the previous POSIX subsystems of Windows, but I have gathered some experience with WSL. As I am also a Cygwin user, I wanted to see if it was able to replace my current setup, therefore availability, compatibility with other tools, and so on.

Availability

The WSL is integrated with the operating system. You might therefore think that given some Windows machine, you can always expect to find a bash shell and work with it.

Unfortunately, it’s not the case, and it won’t be in the foreseeable future.

WSL is available only for the x64 version of Windows and is disabled by default. For enabling it you need to change a couple of system settings and install a GNU/Linux operating system like Ubuntu.

On the other hand, also Cygwin is not available by default. It needs to be downloaded and installed, but

  • it also works on x86 systems

  • it works on older Windows versions

  • it does not require to change any windows configuration/it can be installed as any other program

Future updates

I fear that WSL will suffer a fate similar to Internet Explorer. It is highly integrated with the system, and you’ll need to upgrade to the latest Windows version to also get the Linux subsystem (partially) updated.

The Linux subsystem uses the Ubuntu repository and uses unmodified Linux binaries, but Microsoft needs to support the system calls that are used by those binaries. If a newer version of the Operating system has been released, it makes little sense to add new features to the old one. Thus it is plausible that users that won’t upgrade their system to the latest version, won’t be able to get the latest features if they want them.

Cygwin on the other hand is much more decoupled from the Windows version, like third-party browsers. You can run the latest version even on an older operating system until support is discontinued.

Until now, in practice, support has been discontinued only after Microsoft discontinued support for its system. Similarly like it happened with Firefox and Chrome for older Windows versions compared to IE.

These are of course speculations, but not unfounded.

Cygwin supported Windows XP, which is not supported anymore since 2015, until 2016, and it does still support Windows Vista. You could get the latest Cygwin version for Windows XP one year later official support has been discontinued.

Actual comparison of the system

Supposing that we have a recent Windows version and WSL enabled, let’s compare WSL with Cygwin.

Terminal emulator

The terminal emulator is the first tool one will have to use to enter the Posix subsystem. It’s cmd :-( Fortunately, you can install another emulator, but it would have been much better providing a more modern one by default.

Environment integration

Enter WSL, the first thing you get asked is to create a new account with a different password. This was a little bit unexpected, why should I need to add another account?

WSL and Windows are different worlds (with some overlaps). You can’t edit Linux files under windows or navigate it’s file system directly with explorer.

Therefore all the WSL processes will run as a different user, and those are not visible to the Windows user.

Permissions won’t match, the home directory will not be the same as the one under windows, and so on.

Cygwin may not be perfect, but the system integration is much better.

It is possible, for example, to edit Cygwin configuration files with Windows native tools. And of course, it is also possible (and it’s one of the first things I do), to set the Cygwin home directory at the same location as my windows home.

This makes it possible to use the same configuration for Windows native programs, and programs in Cygwin, for example, git or other command-line tools, without copy-pasting my configuration file in different locations.

This has been the biggest disappointment. As WSL is provided directly by Microsoft, I hoped that the two systems would have been somehow integrated.

At that point I realized, that many command-line tools I wanted so badly under Cygwin, like htop and sudo, and that are available with WSL, are irrelevant. sudo works, but it won’t give you Windows Administrator permissions, you will "only" be root inside WSL (AKA upgrading packages and so on). htop works too, but it will only show the processes of the Linux subsystem.

And worse yet, the two systems, have a completely separated network configuration. /etc/hosts is, for example, not linked to %SystemRoot%\System32\drivers\etc\hosts.

So WSL can be viewed as a virtual machine, from where you can call windows programs, but cannot provide a good integration like Cygwin.

Path conversion issues

So tried to open some file, navigate the filesystem. Of course, some Windows applications, like explorer.exe, won’t accept POSIX paths…​. fortunately at some point wslpath, has been added.

Available Tools

The WSL gives you, theoretically, the whole Ubuntu repository. That’s a lot of programs. Surely more than those provided by Cygwin, which is a great thing.

As mentioned before, many tools I would like to have, like htop and sudo, are nice to have but not what I really wanted if they do not integrate with the Windows world. And other Tools, that can be really useful for a POSIX system inside the Windows system, are not there too. There is for example no tool for accessing the Windows registry.

Issues with AV

At first, I thought that the Ubuntu repository were not working. The connection was incredibly slow, even with Cygwin sometimes it takes a lot of time updating the system but not connecting to the network and downloading the required packages.

Then I found out that the AV was blocking the connection, Microsoft is aware of this issue, and hopefully most AV vendors too. Also, Cygwin has this issue from time to time, the installer has even an option for disabling buggy antiviruses (lucky me I never needed it). So this is not WSL or Cygwin’s fault, lets hope that most AV updates their products.

WSL2

Not all syscalls have been implemented in WSL. For example, it is not possible to execute x86 programs, nor it is foreseeable that WSL is going to be developed further, as there is now WSL2, an integrated virtual machine that runs the Linux kernel.

WSL2 is also currently problematic as it actually breaks other virtualization programs like VirtualBox and VMWare.

Conclusion

WSL is not a tool for administering your machine, WSL2 even less.

It might replace some of my virtual machines, as generally, it should consume fewer resources, but definitely not all of them (thus ruling WSL2 out), and not Cygwin.

It might also remove the need to install some programs under Cygwin if it turns out that it is possible to integrate without too many gotchas both worlds, and if WSL provides some advantage over Cygwin, like better performance.