The programming world has always been divided when it comes to development on an operating system of choice. Some developers prefer using Windows which is a popular and easy-to-use operating system, whereas the others who prefer to have more control over their operating system opt to use some flavor of Linux. This raises some key issues when developing the applications that are required to run on both a Windows and a Linux machine. There was a severe need to fill the gap that would enable the cross platform development from just one operating system. This divide was filled with the advent of the Windows Subsystem for Linux.
The Windows Subsystem for Linux (WSL) is a popular tool which is developed by Microsoft that allows the Windows users to run a Linux file system and install the Linux binaries on Windows. This means that the tools and softwares that are specifically made for Linux can now be installed and used on the Windows operating system as well. Moreover, WSL enables the Windows users to have a Linux terminal right in their Windows instance which powers the development of cross platform applications.
In this guide, we will learn how to install the WSL on a Windows machine and how to configure it to get the best results possible. We will also discuss about the different ways in which WSL can be used so that the cross platform application development can be made easy and accessible for everyone.
Installation
There are a couple of steps that you need to follow to ensure the proper installation and initialization of the WSL on your Windows machine. They might look a bit intimidating at first, but not to worry, this step-by-step guide will surely lead you to success.
1. The first thing you need is the Windows PowerShell.
Go to the Start menu, look for the PowerShell and run it as administrator.
The screen should look something like this:
2. Type the following command into the PowerShell instance and hit enter.
This command ensures that all of the necessary requirements that are needed to run the WSL are enabled on your machine. After that, it installs a Linux distribution on your machine which, by default, is the most recent stable Ubuntu release.
Note: You need to restart your system after installation for the changes to take effect.
3. After restarting your system, you will be greeted with a terminal screen such as the following:
4. After the installation is complete, you will be prompted to configure the initial setup of your fresh Ubuntu install.
You should now complete the setup by following along with the prompts and providing the required information as you would on a new Windows machine.
5. You should now have a new Ubuntu terminal open in front of you. Any Linux Bash command that you type in here will work as expected on a Linux machine.
In our case, we named our fresh install as ss10.
To test our new Ubuntu install using WSL, we now try to use the sudo apt-get update command to update the repositories that the apt package manager has available.
As expected, the apt package manager is now available on our Windows machine. This enables us to use our Windows machine as we use any Linux distribution.
Note: In the event that you want to install a distribution other than the default Ubuntu in step 2 instead of running the command wsl –install, you should run the following command which specifies the distribution that you want to install:
This command installs the Linux distribution of your choice.
If you are not sure what distributions you can install, you can run the following command which lists all of the available Linux distributions on WSL:
or
Why Use the WSL
WSL is geared towards developers since it enables the programmers to build the cross platform applications that make use of one or the other operating systems features. For example, if your web application makes use of a Linux deployment server environment, instead of partitioning your disk to dual boot Linux alongside your Windows, you can just make use of WSL. Having access to all of Linux’s terminal and development features baked right into your Windows operating system allows you to easily manage all of your cross platform development needs.
WSL makes the process of development and deployment using a Continuous Integration/Continuous Delivery pipeline really simple. Consider that you are developing a web application that needs to be tested on a Linux machine before being deployed. You can quickly spin up an instance of the web application on a Linux localhost environment using the Ubuntu Bash shell that you get with WSL and test your application on a Linux system. If it passes all of the test cases that you set out, it can be deployed. If it does not, you can fix it further using the Bash on Linux and then deploy it when it is ready to be rolled out. The possibilities that the WSL opens up for your development needs are endless.
Conclusion
With so much of the development workflows depending on one another, with one operating system being good at certain types of tasks and the other being good at some other types of tasks, having a tool that enables you to quickly switch between two different operating systems is a blessing in disguise.
Developers who need Linux for their deployment and testing needs, or for their Linux server environment and tool needs, having an instance of Linux and the Bash terminal built right into their Windows machine is something that most people could only dream of. With Windows Subsystem for Linux, this dream is now a reality and the entire development community is better off it.
If your work revolves between using Windows and Linux together and you cannot continue working on two separate machines for each operating system or if the virtual machines aren’t simply cutting it for you anymore, we suggest that you give the WSL a shot. It will definitely improve your workflow and make it more efficient.