maze88.dev


No Linux? Windows Subsystem for Linux!

Michael Zeevi

Intro

This post will focus on Windows Subsystem for Linux (WSL), its advantages (over a conventional VM running Linux), setting it up and some tips for getting started with it.

Background

Sometimes you want your Linux environment, but for security reasons your workplace/company/customer enforces usage of standard issue “uniform” Windows computers (not that Linux is not secure, just that IT teams often choose to not manage multiple security tools & policies for different operating systems). In these cases we have a few options...

One option is creating a “classic” Virtual Machine (using Virtual Box, for example), reserving a portion of your host system’s resources (memory, storage, etc.), and installing a full Linux image (such as Ubuntu) on it.

Another option, is to use WSL with a Linux distribution (such as Ubuntu) from the Microsoft Store, which we’ll discuss below.

Note: I won’t touch options like CygWin or MinGW, because they are riddled with differences such as not actually supporting Linux packages (instead they need them to go through modifications before even being compiled).

Advantages

Some of the advantages that make WSL standout:

Caveats

Nothing is perfect (not even Linux), definitely not WSL (it runs on Windows after all..), so here are some slight disadvantages:

Setup

WSL is a Windows feature that must be enabled. Since it uses a VM behind the scenes, one must also enable hardware virtualization in your computer’s BIOS.

Setup steps (assuming virtualization is already enabled in BIOS):

  1. Run Powershell as Administrator and input the following commands:

    dism.exe /online /enable-feature /all /norestart /featurename:VirtualMachinePlatform
    dism.exe /online /enable-feature /all /norestart /featurename:Microsoft-Windows-Subsystem-Linux
  2. Open the Microsoft Store (you can search for it from Start Menu), search for and install your desired Linux distribution (Debian or Ubuntu are solid choices) and Windows Terminal (which is a more feature-rich client than the default client - for example, it allows opening multiple tabs).

  3. Run Windows Terminal and go into Settings. Under Startup, set Default profile to the Linux distribution you got last step.

  4. Still in Settings, under Profiles select your Linux distribution and set the Starting directory to //wsl$/<YOUR_DISTRO_NAME>/home/<YOUR_USER_NAME> (this will make WSL boot into your Linux home directory, insted of the [default] Windows one).

  5. The first time you launch your new WSL distribution it will run its setup and prompt you for setting a root user password, and creating your own user. Do this.

Follow-up actions and tips

After running your new WSL Linux distribution for the first time, here are a few useful things to do:

Additional info

Conclusion

As much as we (or at least, I) strive to be at home and in our Linux systems, sometimes we are forced to work in slightly less “ideal” conditions...

If you need to work with a Linux system from within a Window host, I recommend using WSL. It is as close to a native Linux experience as one can get, from within Windows, without coming on expense of other criteria such as performance.

WSL is one of the best ways I’ve found for achieving this.