DevOps craft is tough, no doubts. If you’re a big Windows fan, it makes the business even tougher, as there are tasks that could only be performed in Linux. This article is not about the profession challenges, but rather about the approaches of how you could resolve ones. There are several categories of tasks you may need Linux for:
- Running or developing Bash shell scripts
- Running Linux-specific workloads
- Testing in Linux environment
- Doing the first steps in learning Linux, etc., etc.
Normally, you would run a Linux virtual machine (VM) either locally or in the cloud for the purpose. However, there’s a better option available. The Windows Subsystem for Linux (WSL) allows running a GNU/Linux environment, including most command-line tools, utilities, and applications directly on Windows, unmodified, without the overhead of a traditional virtual machine or the dual-boot setup. Compared to a full Linux VM, WSL requires fewer resources (CPU, memory, and storage) and enables you to use Windows apps and Linux command-line tools on the same set of files if you wish. Sound cool, huh? How do we get there?
First thing first, we need to enable the respective feature (i.e., Windows Subsystem for Linux). It can be done via Control Panel -> Programs and Features -> Turn Windows features on or off… or, the cool way of doing things is a command line with elevated privileges (i.e., running as an Admin):
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
This will work for the newest and older Windows distributions (1903+):
The next step - download the Linux kernel update package from here and install it. Set WSL 2 as the default version of WSL (for better performance):
wsl --set-default-version 2
Even though Ubuntu Linux is my personal preference, it is not a requirement, and you can install another Linux distribution from the Microsoft Store. Once installed, you can run it right from the MS Store window. In case you closed it right after the installation, you’ll find the Linux system shortcut in the Windows stratum menu. It’ll take a few moments to start for the first time, and right after, you’ll have a fully functional Linux environment ready for the upcoming DevOps endeavors!