It seems odd to invite the competition in, but Microsoft now lets you run Linux inside Windows. It’s easier to install than you think and more flexible and powerful than we imagined.
Why Install Windows Subsystem for Linux?
It seems contradictory to install one operating system (OS) inside another. What’s the point? And why Linux? We can think of six reasons to use Linux in Windows off the top of our heads.
1. Windows Subsystem for Linux is Free and Easy
The most obvious answer is that Linux is free. But what good is something free if it’s hard to use? The good news is that Windows Subsystem for Linux (WSL) is easy, simple, and fast to install or uninstall, so it’s worth trying if you’re just curious about Linux.
2. Windows Subsystem for Linux Doesn’t Require a Virtual Machine
If you don’t want to install a virtual machine (VM) host like Hyper-V, VirtualBox, or VMWare, WSL is the way to go. It takes up less space and resources like CPU and RAM too.
3. Windows Subsystem for Linux Can Use Many Linux Distributions
At the time of writing, 17 Linux distributions (or “distros”) were available in the Microsoft Store. These include different versions and variations of Ubuntu Desktop and Server, Debian, Kali, SUSE Linux Enterprise Server, OpenSUSE, and Oracle Linux.
You also can use the following PowerShell command to see all available distros:
wsl –list –online
4. Windows Subsystem for Linux for Career Development
You could learn about Linux and various Linux distros like Ubuntu, Debian GNU/Linux, Kali, and Alpine WSL for work or school. Linux has a significant market share of servers, and more organizations are using Linux for the desktop.
Students can use it for tutorials instead of going to the computer lab. Security researchers can use Kali and other Linux hacking distros and its many included tools. Many web developers, programmers, and artificial intelligence researchers may use Debian or Alpine WSL as their development environment as they have built-in developer tools.
5. Windows Subsystem for Linux for Open Source Apps
Most open-source software (OSS) is developed first for a Linux environment. As a result, OSS is becoming the standard in several industries, like game development, graphic design, and Internet of Things (IoT) embedded systems.
Consider all the open source software, which is often free. Wish you had Photoshop? Consider using GIMP. Want to learn CAD but can’t afford AutoCAD? Try OpenSCAD. Want to take your video editing to the next level, but Adobe Premiere is out of reach? Linux has Openshot.
Even more impressive is that you can run these Linux GUI apps in their windows as if they were Windows apps. There’s no need for a separate virtual machine in Hyper-V, VirtualBox, or a second physical computer. You could use Visual Studio in Windows and do photo edits in GIMP on Linux without disturbing your workflow.
6. Windows Terminal Runs Multiple Distros at Once
If you’re a fan of Windows Terminal and its multi-tab feature, you’ll love that you can run several Linux distros simultaneously, each in its own tab.
Should I use WSL 1 or WSL 2?
There are two versions of WSL: WSL 1 and WSL 2. WSL defaults to version 2. That’s fine for most people. However, if you’re not sure your system can handle a full Linux kernel install, or you will not use things like Docker, then WSL 1 is fine.
The version is easy to update if you change your mind. As an administrator, open PowerShell or the Command line and use the following wsl.exe command:
wsl –set-default-version 2 or wsl –set-default-version 1
Install Windows Subsystem for Linux with PowerShell
You can install WSL with either PowerShell or the command line interface (CLI). If you haven’t learned PowerShell, that’s okay. The wsl.exe commands work in either.
- Open PowerShell as an administrator and run the cmdlet wsl –install. This installs the WSL 2 version with a full Linux kernel and the Ubuntu distro by default.
If the wsl.exe help text shows, WSL is already installed.
It takes a few minutes to install and then prompts you to reboot Windows.
- When Windows reboots and you sign in, a bash shell window opens, and the Ubuntu installation continues. It will ask you to Enter new UNIX username and New Password. After you enter these, the installation is complete.
Note: This installs the bash shell for Ubuntu. It’s not the graphical user interface (GUI). There are additional steps and prerequisites to enable that. However, you can now use Linux bash shell commands on your Windows computer.
Install Windows Subsystem for Linux with Control Panel
- Open the Start menu and select Control Panel.
- Select Programs and Features.
- Select Turn Windows features on or off. This requires administrator privilege.
- Scroll down and select Windows Subsystem for Linux and then select OK.
The installation begins. When it’s done, the Windows needs to reboot your PC message shows. Select Restart now.
After the restart, open Ubuntu on Windows from the Start menu, or in PowerShell or Command Prompt, use the wsl.exe command.
How Do I Uninstall Windows Subsystem for Linux?
To remove WSL, you must uninstall any Linux operating systems first. You can then remove the supporting components in Windows. It’s easiest to do this through Windows settings.
- Open Windows Settings, go to Apps, then select Apps & features.
- Search for the Linux distros you installed. Select the vertical three-dot menu and select Uninstall.
- Search for “windows subsystem,” select the three-dot menu, and then select Uninstall. Do this for Windows Subsystem for Linux WSLg Preview and Windows Subsystem for Linux Update if those are there.
- Restart Windows, and WSL should be uninstalled.
How Do I Access the Linux File System from Windows?
Unlike using Linux in a virtual machine, it’s easy to access Windows files from Linux and vice versa.
Open File Explorer and select Linux in the navigation pane on the left. When moving files between Windows and Linux, make sure you use a copy, not the original. There are some filetype compatibility issues, and sometimes the file gets corrupted.
How to Fix the Error Message “wsl.localhost is not accessible”
You may get this error the first time you open the Linux filesystem through File Explorer.
Windows treats this connection like a physical connection between Windows and Linux computers. So you must tell it the network exists and is accessible. You’ll do this through the Windows Registry. If you’re not comfortable working in the Registry, ask someone who is. A mistake in the Registry can cause Windows to stop working. Always make a backup of the Registry, too.
- Open the Registry Editor. In the left pane, navigate to the following location:
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlNetworkProvider/HwOrder
- On the right, double-click the PROVIDERORDER key.
- Add P9NP (followed by a single comma and no spaces) to the front of the list and then select OK.
- Back in the NetworkProvider container, open the Order key. Double-click PROVIDERORDER on the right.
- Add P9NP to the front of the list (one comma, no spaces), select OK, and then close Registry Editor.
You can open the Ubuntu filesystem through Windows File Explorer now. If the error persists, restart Windows, and it should work.
How Do I Access the Windows File System from Linux?
- In the Linux bash shell, use the command cd ../.. to move to the root. Then use the ls command to list the directories and files. You’ll see that they’re all Windows directories and files.
- To find your files, use the following command to get to your documents folder, where username is the name of your user directory in Windows:
cd users/username/documents
If you need to access something else, just use cd and ls until you find it. Ensure you only copy files, not move them, due to the risk of corrupting the file.
What Else Can I Do With Windows Subsystem for Linux?
When you enable WSL, you’ve got an entire Linux environment on your Windows computer. Or maybe several Linux environments. Whatever you can think of doing in Linux, you can now do. Take a look at our Linux-related articles and tutorials to get some ideas.
Source by helpdeskgeek.com