Photo by Tadas Sar
Introduction to Windows Subsytem for Linux
Eric Stober / November 7, 2024
Windows Subsytem for Linux (WSL) is a feature of Microsoft Windows that allows for using a Linux environment without the need for a separate virutal machine or dual booting. This post will dicuss my recent setup and usage of WSL.
What is WSL?
Windows Subsystem for Linux (WSL) is a compatibility layer developed by Microsoft that enables users to run Linux distributions natively on Windows. It lets you use a Linux terminal and run Linux applications on a Windows computer without the need for a virtual machine or dual-booting.
Why use WSL?
Using Windows Subsystem for Linux (WSL) can bring substantial benefits, especially for developers, system administrators, and data scientists. WSL simplifies the workflow for users who need Linux tools on Windows, making it easier and faster to accomplish tasks that would otherwise require a full virtual machine setup or dual-booting. This can be a huge advantage for development, testing, and productivity. Here are some key features of WSL:
- Seamless Linux Integration on Windows: WSL provides a Linux terminal directly on Windows, allowing you to run Linux distributions without setting up a virtual machine or dual-booting. This lets you use Linux commands alongside Windows application seamlessly. You can also invoke Linux commands from the Winows command line and vice versa.
- Ideal for Development Workflows: Many development tools and languages (Node.js, Python, Ruby, etc.) are originally designed for Linux, and WSL allows you to use them without the hassle of cross-platform configuration. It's perfect for web development, as many server technologies and libraries are natively compatible with Linux, such as Apache, Nginx, and Docker.
- Access to Linux Command-Line Tools and Package Managers: With WSL, you have access to tools like grep and powerful Linux package managers (e.g., apt, yum). This enables you to install software, manage dependencies, and perform tasks just as you would on a traditional Linux system.
- Shared File System Access Between Windows and Linux: You can access your Windows files from Linux and vice versa. This makes it easy to share files across environments, edit code in Linux directory with a Windows editor, or transfer files between applications.
- Improved Performance and Efficient Resource Usage: WSL includes a real Linux kernel and uses a lightweight virtual machine, which enhances compatibility and performance. This makes it possible to run complex applications and services with near-native speed. Unlike a traditional virutal machine, WSL doesn't require a large amount of RAM or CPU resources.
- Support for GUI Linux Applications: WSL supports Linux graphical user interface (GUI) applications, which means you can run Linux-based IDEs, graphical editors, and other software.
- Great for Cross-Platform Development and Testing: WSL is particularly useful for developers working on applications that need to run on both Windows and Linux, such as web applications. You can write, build, and test applications in a Linux environment without leaving Windows.
- Experimentation: If you are experimenting with Linux-based applications, WSL provides a safe, easy environment. You can install, modify, and uninstall Linux distributions quickly without affecting your main OS setup.
How to install WSL
Open PowerShell or Windows Command Prompt in administrator mode by right-clicking and selecting "Run as administrator", enter the below command, then restart your machine.
wsl --install
This will will enable the features required to run WSL and install the Ubuntu Linux distribution. Ubuntu is the default distribution installed with WSL but this can be changed.
Change the default Linux Distribution installed
Other Linux distributions can be installed by adding the -d
flag to the install command.
wsl --install -d <DistributionName>
Replace <DistributionName>
with the name of distribution you would like to install.
The list of available Linux distributions can be viewed by entering:
wsl --list --online
Conclusion
Windows Subsystem for Linux (WSL) is a great tool for developers like myself to run an environment that accomodates both Windows and Linux tooling. I've just recently set it up for myself and began making use of it's features. I'm excited to explore WSL more and develop a workflow that suites me.