For a full Linux experience, there’s no substitute for a full install. But if you’re a Windows user wishing for more Linux in your life, Windows Subsystem for Linux (WSL) is a great place to start. It gives you a Linux kernel in a lightweight virtual machine that runs right alongside Windows and can interact with its file system. Getting a Linux distro up and running on your Windows machine is pretty easy whether you’re just learning Linux or want to use a Linux development environment, so it’s worth a shot if you’re at all curious. Here you’ll learn how to install Linux on Windows 10 with WSL.
What you’ll get
You’ll end up with a Linux virtual machine you can run on Windows. You can get Ubuntu, Debian, Kali, openSUSE, and SLES, and you can have them installed and running at the same time. For the most part, you can do anything in a WSL installation that you would do on a separate Linux installation, like using the Bash shell, running command-line tools, or installing Linux (command-line) applications. You can switch quickly between Linux and Windows and, perhaps most importantly, access your Windows files and programs from inside the Linux shell.
What you don’t get is a GUI. WSL is command-line only, so you’ll have to learn some basic Linux commands.
Installing and Setting Up WSL
You’ll need to be running an up-to-date version of Windows 10 for this to work, but that’s just about the only requirement. The instructions below will set you up with the most recent version of Windows Subsystem for Linux (WSL2, as of June 2020), though you’ll have to keep the Linux installation up to date yourself using:
Note: steps 1, 2, and 3 use the PowerShell command line to enable the WSL feature. If you’d rather use the GUI, just enter “Windows Features” in the Windows search bar, find “Windows Subsystem for Linux,” and check the box. Using PowerShell is recommended, though.
1. Open PowerShell. Make sure you use “Run as administrator.”
2. Paste in the following script:
3. If it prompts you to restart, do that. Otherwise, move on.
4. Open the Microsoft Store and search for “Linux” to see all your options. Here, we’ll install Ubuntu.
5. Click the “Install” button.
6. Wait for it to download, then launch Ubuntu. In the future, you can do this from your Start Menu.
7. Set up any username/password combination you want. It doesn’t have to be the same as your Windows login.
8. Update your installation using:
9. If you want to install packages, you can use:
Basic Linux commands
If you’re familiar with basic Linux command line navigation, you can skip down a little bit. Otherwise, the following are some basic commands you’ll need to know to move around in a Linux command line.
Using WSL with Windows
If you want, you can use your Linux installation as its own system on Windows, with totally separate files and programs. That’s fine, and you may actually want some files stored on Linux for its speed advantages, but one of the big perks of WSL is that you can interact with your Windows files and folders by effectively mounting the drive to your Linux system. This enables you to use Linux with anything you have on Windows, thus keeping all your stuff in the same place.
Using Linux commands in a Windows shell like PowerShell or command prompt is easy. Just use:
For example, if you want to list all the content of your current directory using the Linux command, just enter:
This will execute the Linux command on Windows without opening the actual operating system.
If you want to start the entire operating system from inside PowerShell or cmd, that’s also easy. Just run:
Eventually, though, you’ll probably wonder how to access Windows directories from inside your Linux system. The key here is that Windows is essentially mounted as an external drive to the Linux system, so Linux can use it as storage, making it pretty much the same as using your OS to edit files on a flash drive.
1. Open your Linux terminal (Ubuntu, in this case) as a Windows administrator.
2. Access your Windows C:\ drive by entering:
To confirm you’ve accessed it, run:
to see the files and folders.
3. Try creating a directory. Run:
Open File Explorer and check your C:\ drive to confirm that Ubuntu created a folder there.
4. Enter the directory by typing:
5. Create a file using:
6. Edit the file using:
Enter a few words, then press Ctrl + O to save and Ctrl + X to exit.
7. Check your Windows file system again. You should see a text file with the content you entered.
8. If you want to, you can navigate to any other folder or document on your Windows drive and edit it using Ubuntu.
Now let’s say you want to access your Linux files in Windows or maybe just want a GUI representation of your filesystem. No problem. Just navigate to the Linux directory you want to see and enter:
. at the end stands for the current directory, and if you include it, explorer.exe will launch a Windows Explorer window that shows you your Linux files.
You can actually launch other Windows apps and run Windows commands from Linux as well. For example:
What else can you do?
Now that you know how to install Linux on Windows 10 and how it interacts with Windows, you can do pretty much whatever you want. You can run programming languages, run local servers, use a Windows IDE to work in the Linux shell, run multiple Linux distros at the same time, or just play around with Linux to get comfortable with the command line. The price of failure is pretty low. If you mess something up, resetting or reinstalling your Linux distro is pretty easy.
Image credits: Tux