Windows 10’s Anniversary Update added support for Linux environments to Windows 10 back in 2016. But don’t be deceived: this is more than just a Bash shell. It’s a full compatibility layer for running Linux applications on Windows.
We’ve covered a lot of the things you can do in Windows 10’s new Bash shell, so we’ve rounded up all those guides into one mega list here, for your convenience.
Getting Started with Linux on Windows
You can install a Linux environment and Bash shell on any edition of Windows 10, including Windows 10 Home. However, it does require a 64-bit version of Windows 10. You just have to enable the Windows Subsystem for Linux feature, and then install your chosen Linux distribution—for example, Ubuntu—from the Windows Store.
Install Linux Software
The easiest way to install Linux software in your Ubuntu (or Debian) environment is with the
apt-get command. (The
apt command also works.) This command downloads and installs software from Ubuntu’s software repositories. You can download and install one or more applications with just a single command.
As this is a more-or-less full Ubuntu userspace environment, you can also install software in other ways. You can compile and install software from the source code just as you would on a Linux distribution, for example.
If you’ve installed another Linux distribution, use the commands for installing software on that specific distribution instead. For example, openSUSE use the
Run Multiple Linux Distributions
The Fall Creators Update also enabled support for multiple Linux distributions, where previously only Ubuntu was available. Initially, you can install Ubuntu, openSUSE Leap, SUSE Linux Enterprise Server, Debian GNU/Linux, or Kali Linux. Fedora is also on the way, and we’ll probably see more Linux distributions offered in the future.
You can have multiple Linux distributions installed, and you can even run multiple different Linux environments at the same time.
If you’re not sure which to install, we recommend Ubuntu. But, if you need a particular Linux distribution—maybe you’re testing software that will run on a server running SUSE Linux Enterprise Server or Debian, or you want the security testing tools in Kali Linux—they’re available in the Store alongside Ubuntu.
Access Windows Files in Bash, and Bash Files in Windows
Your Linux files and Windows files are normally separated, but there are ways to access your Linux files from Windows and your Windows files from the Linux environment.
Linux distributions you install create a hidden folder where all the files used in that Linux environment are stored. You can access this folder from Windows if you want to view and back up Linux files with Windows tools, but Microsoft warns that you shouldn’t modify these Linux files with Windows tools, or create new files here with Windows applications.
When you’re in the Linux environment, you can access your Windows drives from under the /mnt/ folder. Your C: drive is located at /mnt/c and your D: drive is located at /mnt/d, for example. If you want to work with files from within the Linux and Windows environments, place them somewhere in your Windows file system and access them through the /mnt/ folder.
Mount Removable Drives and Network Locations
The Windows Subsystem for Linux automatically mounts fixed internal drives under the /mnt/ folder, but it doesn’t automatically mount removable drives like USB drives and optical discs. It also doesn’t automatically mount any network drives that may be mapped on your PC.
However, you can mount these yourself and access them in the Linux environment with a special mount command that takes advantage of the drvfs file system.
Switch to Zsh (or Another Shell) Instead of Bash
While Microsoft originally pitched this feature as a “Bash shell” environment, it’s actually an underlying compatibility layer that allows you to run Linux software on Windows. That means you can run other shells instead of Bash, if you prefer them.
For example, you can use the Zsh shell instead of Bash. You can even have the standard Bash shell automatically switch to the Zsh shell when you open the Linux shell shortcut in your Start menu.
Use Bash Scripts on Windows
Thanks to this environment, it’s actually possible to write a Bash shell script on Windows and run it. Your Bash script can access your Windows files stored under the /mnt folder, so you can use Linux commands and scripts to work on your normal Windows files. You can also run Windows commands from within the Bash script.
Run Linux Commands From Outside the Linux Shell
If you just want to quickly launch a program, execute a command, or run a script, you don’t even need to launch the Bash environment first. You can use the
bash -c or
wsl command to execute a Linux command from outside the Linux shell. The Linux environment simply runs the command, and then quits. If you run this command from within a Command Prompt or PowerShell window, the command prints its output to the Command Prompt or PowerShell consoles.
You can do a lot with
bash -c or
wsl. You can create desktop shortcuts to launch Linux programs, integrate them into batch or PowerShell scripts, or run them any other way you’d run a Windows program.
Run Windows Programs From Bash
As of the Creators Update (which came out in Spring 2017), you can run Windows programs from within the Linux environment. This means you can integrate Windows commands alongside Linux commands in a Bash script, or just run Windows commands from the standard Bash or Zsh shell you may already be using.
To run a Windows program, type the path to an .exe file and press Enter. You’ll find your installed Windows programs under the /mnt/c folder in the Bash environment. Remember, the command is case-sensitive, so “Example.exe” is different from “example.exe” in Linux.
Run Graphical Linux Desktop Programs
Microsoft doesn’t officially support graphical Linux software on Windows. The Windows Subsystem for Linux feature is intended for running command-line programs developers might need. But it’s actually possible to run graphical Linux desktop programs on Windows using this feature.
This won’t work by default, however. You’ll need to install an X server and set the
DISPLAY variable before graphical Linux desktop programs will run on your Windows desktop. The simpler the application, the more likely it is to work well. The more complex the application, the more likely that it’ll try to do something Microsoft’s underlying Windows Subsystem for Linux doesn’t yet support. All you can do is give it a shot with these instructions and hope for the best.
Choose Your Default Linux Environment
If you have multiple Linux distributions installed, you can choose your default installation. This is the distro used when you launch the Linux distribution with the
wsl command, or when you use the
bash -c or
wsl commands to run a Linux command from elsewhere in Windows.
Even if you have multiple Linux distros installed, you can still launch them directly by running a command like
opensuse-42. The exact command you’ll need is spelled out on each Linux distribution’s download page on the Microsoft Store.
Quickly Launch Bash From File Explorer
You don’t have to launch the Linux shell from its shortcut icon. You can quickly launch it from within File Explorer by typing “bash” into the address bar and pressing Enter. Your default Linux distribution’s Bash shell will appear, and the current working directory will be the directory you had open in File Explorer.
That article also provides instructions for adding an “Open Bash shell here” option to File Explorer by editing the Windows Registry, giving you a convenient context menu option that works similarly to the “Open PowerShell window here” or “Open Command Prompt here” options.
Change Your UNIX User Account
When you first set up Bash, you’re be prompted to create a UNIX user account and set a password. You’re be automatically signed in with this account each time you open the Bash window. If you want to change your UNIX user account—or use the root account as your default account in the shell—there’s a hidden command for changing your default user account.
Uninstall and Reinstall a Linux Environment
After you’ve installed some programs or changed some settings, you might want to reinstall Ubuntu or another Linux distribution and get a fresh Linux environment. This was previously a little complicated, but you can now do it simply by uninstalling the Linux distribution like you would any other application and then reinstalling it from the Store.
To get a fresh system without redownloading the Linux distribution, you can run the distribution’s command along with the “clean” option from a Windows Command Prompt or PowerShell console. For example, to reset Ubuntu without redownloading it, run
ubuntu clean .
If you still have an older Linux environment installed—one that was installed prior to the Fall Creators Update—you can still uninstall it with the lxrun command.
Upgrade Your Ubuntu Environment
After the Windows 10’s Fall Creators Update, you now have to install Ubuntu and other Linux environments from the Store. When you’ve do that, they’ll be automatically updated to the latest versions without any special commands.
However, if you created a Bash environment on an older version of Windows, you’ll have an older Ubuntu environment installed. You can just open the Store, and install the newest Ubuntu from the Windows Store to upgrade.
Enterprising geeks will no doubt figure out other interesting things you can do with the Linux environment in the future. The Windows Subsystem for Linux will hopefully continue getting more powerful, but don’t expect Microsoft to officially support graphical Linux desktop applications any time soon.
- › How to Run Command Prompt Commands from a Windows Shortcut
- › What’s the Difference Between Bash, Zsh, and Other Linux Shells?
- › How to Unzip or Extract tar.gz Files on Windows
- › How to Run Windows Programs from Windows 10’s Bash Shell
- › What Is Windows 10 S, and How Is It Different?
- › Did Linux Kill Commercial Unix?
- › How to Find Your IP Address From CMD (Command Prompt)
- › Samsung’s Galaxy Book 3 Laptops Have 120Hz AMOLED Displays