Windows 10’s Anniversary Update offers a big new feature for developers: A full, Ubuntu-based Bash shell that can run Linux software directly on Windows. This is made possible by the new “Linux Subsystem for Windows” Microsoft is adding to Windows 10.
If you’re using an Insider Preview build of Windows 10, you can now install the Bash shell and play with it yourself right now. This feature was added in Insider Preview build 14316, which was only available on the Fast channel at the time this article was written. It’s also only for 64-bit versions of Windows 10.
This isn’t a virtual machine, a container, or Linux software compiled for Windows (like Cygwin). Instead, Windows 10 gains a Linux Subsystem for Windows, which is based on Microsoft’s abandoned Project Astoria work for running Android apps on Windows.
Think of it as the opposite of Wine. While Wine allows you to run Windows applications directly on Linux, the Linux Subsystem for Windows allows you to run Linux applications directly on Windows.
Microsoft has worked with Canonical to offer a full Ubuntu-based Bash shell that runs atop this subsystem. Technically, this isn’t Linux at all. Linux is the underlying operating system kernel, and that isn’t available here. Instead, this allows you to run the Bash shell and the exact same binaries you’d normally run on Ubuntu Linux. Free-software purists often argue the average Linux operating system should be called “GNU/Linux” because it’s really a lot of GNU software running on the Linux kernel. The Bash shell you’ll get is really just all those GNU utilities and other software.
There are some limitations here. This won’t work with server software, and it won’t work with graphical software. It’s intended for developers who want to run Linux command-line utilities on Windows. These applications get access to the Windows file system, but you can’t use Bash commands to automate normal Windows programs, or launch Bash commands from the standard Windows command-line. They get access to the same Windows file system, but that’s it. Not every command-line application will work, either, as this feature is still in beta.
How to Install Bash on Windows 10
To get started, ensure you’re using at least build 14316 of Windows 10. You’ll need to enable Insider Preview builds to get this feature before the Anniversary Update is officially released. This only works on 64-bit builds of Windows 10, so it’s time to switch to the 64-bit version of Windows 10 if you’re still using the 32-bit version.
Once you’re sure you’re using the correct version of Windows 10, open the Settings app and head to Update & Security > For Developers. Activate the “Developer Mode” switch here to enable Developer Mode.
Next, open the Control Panel, click “Programs,” and click “Turn Windows Features On or Off” under Programs and Features. Enable the “Windows Subsystem for Linux (Beta)” option in the list here and click “OK.”
After you do, you’ll be prompted to reboot your computer. Click “Restart Now” to reboot your computer and Windows 10 will install the new feature.
After your computer restarts, click the Start button (or press the Windows key), type “bash”, and press “Enter.”
The first time you run the bash.exe file, you’ll be prompted to accept the terms of service. The command will then download the “Bash on Ubuntu on Windows” application from the Windows Store.
How to Use Ubuntu’s Bash Shell and Install Linux Software
You’ll now have a full command-line bash shell based on Ubuntu. Because they’re the same binaries, you can use Ubuntu’s apt-get command to install software from Ubuntu’s repositories. You’ll have access to all the Linux command line software out there, although not every application may work perfectly–especially in the initial beta releases.
To open the Bash shell, just open your Start menu and search for “bash” or “Ubuntu.” You’ll see a “Bash on Ubuntu on Windows” application. You can pin this application shortcut to your Start menu, taskbar, or desktop for easier access.
If you’re experienced using a Bash shell on Linux, Mac OS X, or other platforms, you’ll be right at home. You don’t need to use sudo, as you’re given a root shell. The “root” user on UNIX platforms has full system access, like the “Administrator” user on Windows. Your Windows file system is located at /mnt/c in the Bash shell environment.
Use the same Linux terminal commands you’d use to get around. If you’re used to the standard Windows Command Prompt with its DOS commands, here are a few basic commands on both Bash and Windows:
- Change Directory: cd in Bash, cd or chdir in DOS
- List Contents of Directory: ls in Bash, dir in DOS
- Move or Rename a File: mv in Bash, move and rename in DOS
- Copy a File: cp in Bash, copy in DOS
- Delete a File: rm in Bash, del or erase in DOS
- Create a Directory: mkdir in Bash, mkdir in DOS
- Use a Text Editor: vi or nano in Bash, edit in DOS
It’s important to remember that, unlike Windows, the Bash shell and its Linux-imitating environment are case-sensitive. In other words, “File.txt” with a capital letter is different from “file.txt” without a capital.
You’ll need to use the apt-get command to install and update the Ubuntu environment’s software. Here are the apt-get commands you’ll need to know:
- Download Updated Information About Available Packages: apt-get update
- Install an Application Package: apt-get install packagename (Replace “packagename” with the package’s name.)
- Uninstall an Application Package: apt-get remove packagename (Replace “packagename” with the package’s name.)
- Search for Available Packages: apt-cache search word (Replace “word” with a word you want to search package names and descriptions for.)
- Download and Install the Latest Versions of Your Installed Packages: apt-get upgrade
Once you’ve downloaded and installed an application, you can type its name at the prompt and press Enter to run it. Check that particular application’s documentation for more details.
Remember, software you install in the Bash shell is restricted to the Bash shell. You can’t access it from the Command Prompt, PowerShell, or elsewhere in Windows. Software in the Bash shell also can’t interact directly with or launch Windows programs, although the Bash environment and Windows have access to the same files on your computer.
However, you can create Bash shell scripts (.sh scripts) and run them with the Bash shell.