Learn to configure a Linux shell on Windows

Learn to configure a Linux shell on Windows

An easy tutorial to configure a Linux shell on Windows without making it your primary OS.

Introduction:

Are you seeking to learn Linux to expand your toolkit without going through the hassle of setting up a virtual environment, or curious to try Linux before choosing to make it your primary operating system, or you're just bored and want to keep yourself from facing the existential dread? If your answer to any of these is yes, you're in the right place.

In this short and easy-to-follow tutorial, we'll learn to configure a Linux shell on Windows.

Windows Subsystem for Linux or WSL:

WSL is a feature of Windows that allows developers to operate both Linux and Window on a single machine. WSL integrates the Linux distribution into the Windows file system, allowing you to access your Windows files from within the Linux shell and vice versa. This enables you to work on files using your preferred Linux command-line tools.

With WSL, you have access to a full-fledged Linux terminal and command-line environment. This allows you to use Linux commands, utilities, and scripting languages as if you were on a native Linux system.

In short, it provides an excellent environment for software development, debugging, and testing.

Configuring a Linux shell:

We'll go over it in steps.

Enable WSL:

Right-click on the start menu and run Windows PowerShell as administrator.

Once it's open, run the following command:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Restart your computer when prompted.

Install a Linux distribution:

Next, you'll have to install a Linux distribution (such as Ubuntu, openSUSE, Kali, Debian, Arch Linux, etc.) of choice. I prefer Ubuntu, so I'm going to install that.

You can install Ubuntu easily from Microsoft store.

Launch the Linux shell:

After the installation is complete, you can either:

  • Launch the Linux distribution from the Start menu.

  • Open the Command Prompt or PowerShell and type the distribution's name (ubuntu) and press Enter.

I recommend using the Command Prompt or PowerShell. Open either of these and type the distribution's name, which in my case is Ubuntu, and press enter.

Some users can get this error:

Installing, this may take a few minutes... WslRegisterDistribution failed with error: 0x800701bc Error: 0x800701bc WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel Press any key to continue...

If this happens, you can simply follow the link, install the latest version of WSL, restart your computer, and go through this step again.

Set up your Linux shell:

If your previous command executed successfully, you'll be prompted to set up your UNIX username and password. It'll look something like this:

Set up a username and password.

Using the Linux shell:

Congratulations! You've successfully configured a Linux shell on your Windows system. Now whenever you've to use the Linux shell, just open Command Prompt or PowerShell, type your Linux's distribution name, and press enter.

It'll look something like this:

In order to exit the Linux shell, just type exit and press enter.

Conclusion:

Now, you can write Linux commands to your heart's content! Please note that this setup requires Windows 10 or a later version with the necessary updates. Also, be aware that while WSL provides a Linux-like environment, it's not a complete replacement for running Linux natively. Some features, especially those related to hardware access or GUI applications, might have limitations.

However, this can be your first step to make Linux your primary OS. Remember me when you do that.

:)

Thanks for reading this blog!