-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
--- | ||
date: 2024-11-07 | ||
draft: false | ||
authors: [gabrielbdornas] | ||
comments: true | ||
categories: | ||
- Linux | ||
- Windows | ||
--- | ||
|
||
# Running Linux on Windows with WSL: A guide for developers and non-developers | ||
|
||
If you've ever wanted to use Linux commands within your Windows environment, the **Windows Subsystem for Linux (WSL)** is an excellent tool by Microsoft. | ||
It allows you to run Linux distributions on Windows, primarily through the command line, but also supports some graphical applications. | ||
|
||
<!-- more --> | ||
|
||
## What is WSL? | ||
|
||
First things first. | ||
What is WSL? | ||
It's a tool that enables Linux to run directly within Windows, which is helpful for software development, system administration, or just exploring Linux tools without leaving Windows. | ||
Originally introduced as WSL1, WSL2 is an improved version that offers more robust performance and a real Linux kernel for enhanced compatibility. | ||
|
||
## Key benefits of WSL | ||
|
||
1. **Low resource usage**: Unlike full virtualization software like VirtualBox or VMware, WSL uses fewer resources, making it ideal for quickly accessing Linux tools without heavy memory or CPU demands. | ||
|
||
2. **Developer-focused but broadly useful**: While it’s popular with developers, WSL offers useful tools for non-programmers as well, making it a versatile solution for anyone who wants to use Linux utilities within Windows. | ||
|
||
3. **Integration with Windows**: You can access Windows file systems directly from within Linux and vice versa, creating a seamless experience for file management across both environments. | ||
|
||
## WSL usage prerequisites: | ||
|
||
To install the Windows Subsystem for Linux (WSL), your machine needs to meet the following prerequisites: | ||
|
||
1. **Operating System**: | ||
|
||
- **Windows 10** (Version 2004 and higher, with Build 19041 and higher). | ||
- **Windows 11** (any version). | ||
|
||
??? tip | ||
|
||
To check your Windows version and build number press `Win + R` to open the Run dialog, type `winver`, and press Enter. | ||
|
||
2. **System Requirements**: | ||
|
||
- **64-bit Processor**: WSL2 requires a 64-bit processor. | ||
Older 32-bit versions of Windows cannot run WSL2. | ||
- **Virtualization Support**: Your system must support virtualization. | ||
This is typically available on most modern CPUs, but make sure it’s enabled in the BIOS/UEFI 'settings. | ||
|
||
??? tip | ||
|
||
Ensure that virtualization is enabled in your BIOS or UEFI settings. | ||
This is often labeled as Intel VT-x (for Intel processors) or AMD-V (for AMD processors). | ||
|
||
3. **Windows Update**: Make sure your system is up-to-date with the latest Windows updates. | ||
WSL2 requires specific updates that are available in the latest versions of Windows 10 and 11. | ||
|
||
Once you have verified these prerequisites, you can proceed with the installation. | ||
|
||
## Windows 11 WSL installation | ||
|
||
To enable WSL on Windows 11: | ||
|
||
??? info | ||
|
||
If you're using Windows 10, the installation process is a bit different. A quick online search should guide you through it, but if you need any extra help, feel free to ask in the comments below. | ||
|
||
1. Open PowerShell as Administrator. | ||
2. Run the following command: | ||
|
||
```bash | ||
wsl --install # (1)! | ||
``` | ||
|
||
1. :man_raising_hand: This command installs WSL, sets WSL2 as the default version, and installs Ubuntu as the default Linux distribution. **After the installation, you may need to restart your computer**. To install other Linux distributions, use the command `wsl --install -d <distribution-name>`. You can view available distribution options by running `wsl --list --online`. | ||
For a full list of `wsl` command options, use the `--help` flag. For example, you can check the status and list all installed WSL distributions by using `wsl --list --verbose`. | ||
|
||
??? tip | ||
|
||
Install Windows Terminal :octicons-terminal-16: through Microsoft Store to streamline your WSL experience. | ||
|
||
3. After installation, you can launch WSL by searching for "WSL" or "Ubuntu" in the Start Menu :fontawesome-brands-windows:. | ||
|
||
4. When you open WSL for the first time, you'll be prompted to create a Linux username and password for administrative tasks. | ||
??? tip | ||
:warning: When you're prompted to enter your password, you won’t see any characters appear on the screen as you type—this is normal and a security feature. Just type your password carefully and press ++enter++. | ||
|
||
## Accessing files and running linux applications | ||
|
||
One unique feature of WSL is the ability to interact with files across both Windows and Linux environments. | ||
|
||
For instance: | ||
|
||
- Windows directories are accessible from Linux via `/mnt/c`. | ||
- You can open Linux files directly in Windows Explorer by typing `\\wsl$\Ubuntu` (1) in the address bar. | ||
{ .annotate } | ||
|
||
1. :man_raising_hand_tone5: Replace `Ubuntu` in case your linux distribution is different. | ||
|
||
## Example: running a simple web server | ||
|
||
A quick example of how WSL can be used effectively is running a web server: | ||
|
||
1. In WSL, navigate to the directory where you want to serve files. | ||
2. Run a simple Python HTTP server: | ||
|
||
```bash | ||
python3 -m http.server 8000 | ||
``` | ||
|
||
3. Access this server in a Windows browser by going to `http://localhost:8000`. | ||
|
||
## Final Thoughts | ||
|
||
WSL bridges the gap between Windows and Linux, allowing a streamlined workflow for both development and general Linux usage within Windows. | ||
Whether you're a developer needing a Linux environment or just curious to explore Linux tools, WSL provides a flexible, efficient option. | ||
## References | ||
- [One of the BEST things Microsoft has ever done - How to use WSL (Linux within Windows)](https://youtu.be/o1_E4PBl30s?si=SgUMyhT4YC6uNKaR). | ||
- [How to install Linux on Windows with WSL](https://learn.microsoft.com/en-us/windows/wsl/install). | ||
- [Frequently Asked Questions about Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl/faq). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters