Windows 10 offers a module that enables you to use Bash right on your Windows computer. In this video, walk through enabling Windows Subsystem for Linux and installing a command-line Ubuntu environment.
- I have a confession to make. For a long time, at the beginning of my computing experience, I was a Windows guy. I could administer a Windows NT domain with the best of them. Well, I was pretty good at it, for a high school sophomore. I made fun of my Mac friends, and later, my Linux friends for using an operating system that I thought was too much like a toy, or too hard for a normal human to use. But I learned to embrace other operating systems, and so did Windows. In 2016, Microsoft released the Windows Subsystem for Linux.
To people who had followed Windows for a long time, this seemed like either an absolute heresy or a sudden outbreak of common sense. The Windows Subsystem for Linux, or WSL, lets you run Linux programs right on your Windows desktop, instead of in a virtual machine or through a terminal session. By itself, the Windows Subsystem for Linux is a compatibility layer for Linux executables to run against the Windows kernel. There's no Linux kernel in sight, though. The Windows kernel is running the commands. Using this compatibility layer, we can install various Linux distributions and work with their native tools.
In this episode, I'll enable the Windows Subsystem for Linux here on my Windows 10 PC, and then I'll install Ubuntu from the Windows store. You can also install other distros on your system after enabling Windows Subsystem for Linux. And if you're feeling particularly adventurous, there are resources online that show you how to make your own distro for use with the subsystem as well. When I say that you can install Linux distros from the Windows store, it's important to note that, at least right now, that means pretty minimal distros.
You get Bash, the GNU tools, a package manager, and some other stuff. Basically, a minimal install. No desktop, no office suite, none of the more desktop-oriented tools you might be used to on a live CD or a desktop distro right out of the box. Windows Subsystem for Linux is targeted at developers who want to use Linux tools to interact with files on their Windows desktop in a way that uses fewer resources than a whole virtual machine. Windows Subsystem for Linux is available as an optional feature in Windows 10, Version 1607 and later.
To enable it, open your start menu and search for turn Windows features on or off. Then scroll down to the bottom and click the box next to Windows Subsystem for Linux. Click OK, and then you'll need to restart your computer. After the restart, we'll have the subsystem installed, but we still need to install a Linux distro in order to do anything. I'll open up the Windows store here.
And I'll search for Ubuntu. Here's the installer for Ubuntu 18.04. I'll click it, and then I'll click get. This will download a package containing a Linux root file system and a minimal Ubuntu install, so that'll take a few minutes. If you're not able to use the Windows store, for some reason, you can install Windows Subsystem for Linux and distros using Powershop.
Take a look at this link for more information about that. Ubuntu's installed, so I'll close the store. I'll go to my start menu and choose Ubuntu 18.04. The software will go through an installation process. I'm prompted to enter a username and password, which will create my account for the Ubuntu system. It's different than my Windows account.
And then I'm at a Bash prompt. On Windows! Natively! What a world. Let's take a moment and modify the console here to make this a little easier to see. I'll click on the application icon up here in the top left and choose properties. And then I'll click font and choose something larger, maybe 24 points. You can customize this how you'd like. I'll click OK.
Here at the Bash prompt, I can do normal Bash things. Let's take a look at the Bash version with bash --version. And let's list the root with ls -l and slash. Then let's figure out where the ls command lives with which ls. Looks pretty Linuxy to me. I can even use the APT package manager, here in Ubuntu, to check for updates.
I'll write sudo apt update. Let's see what can be upgraded. Well, I'll do that later. I won't dig too much more into the basic command line stuff. If you'd like to learn more about the Bash environment or working with Linux, be sure to take a look at those episodes in the series, or at our courses that focus on those topics. I mentioned earlier that this installation runs alongside Windows.
That means there's no isolated sandbox to deal with. So I have access to my Windows disk here in the Linux file system. That's mounted at mnt/c, so let's go over there. And let's take a look around. Yep, that's a Windows installation alright. I'll move in, rephrase. I'll move into my Windows Users desktop folder.
And we can work with files here. I'll create a text file. I'll press start D to show my desktop. And here's my file. I can open that up. Rephrase, I can open that up with my text editor and work with the file from the Windows side as well.
So if we can access the Windows drive through the Linux file system, it might occur to you to ask, where's the Linux home folder located on the Windows system? Well, if you go adventuring through your file system, you can find it, but it's much better to work with a Windows file system from Linux than to try to work with a Linux file system from Windows. That's a quick look at the Windows Subsystem for Linux. As I mentioned earlier, it's intended for software developers and it's not a desktop replacement. If you have a place for it in your workflow, I encourage you to explore it further.
For now, though, I'll close this window, which will close out the session, and I'll go back to my Windows desktop. I can start this up again by going to the start menu and choosing the entry for the distro I installed.
Note: Because this is an ongoing series, viewers will not receive a certificate of completion.