Windows 10’s Anniversary Update brings a “Bash on Ubuntu on Windows” environment to Windows 10. 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 Bash on Windows
When you run the Bash program, it will download the Ubuntu system files and set up a Bash environment for
you. Check out our guide to installing it for more.You can install the Bash shell on any edition of
Windows 10, including Windows 10 Home. However, it does require a 64-bit version of Windows 10.
You’ll just have to enable developer mode, add the feature to Windows, and then run the Bash program.
Install Linux Software
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,
The easiest way to install Linux software inside Bash is with the apt-get command. 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.
Access Windows Files in Bash, and Bash Files in Windows
When Bash downloads the Ubuntu system files to your hard drive, it also creates a home folder specifically
for that Bash Linux compatibility environment. These folders are normally hidden, but you can find them
under your Windows user account’s Application Data folder.Your Bash environment files and Windows files
are normally separated, but there are ways to access your Bash files from Windows and your Windows files
from the Bash environment.
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.
Use Zsh (or Another Shell) Instead of Bash
While Microsoft pitches this feature as “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 Bash automatically switch to the
Zsh shell when you open the Bash shell shortcut in your Start menu.
Use Bash Scripts on Windows
Unfortunately, there’s no way to actually launch a Windows program or run a Windows command from within
a Bash script or the Bash shell. However, you can incorporate Bash commands into a Batch script or
PowerShell script, which is pretty handy. For all this and more, see our guide to bash scripts in Windows 10.
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..
Run Linux Commands From Outside Bash
You can do a lot with bash -c. 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.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” command to directly execute a Linux command.
Bash will simply run the command and then quit. If you run this command from within a Command Prompt
or PowerShell window, the command will print its output to the Command Prompt or PowerShell consoles.
Run Graphical Linux Desktop Programs
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. The Bash
feature is just intended for running command-line programs developers might need. But it’s
actually possible to run graphical Linux desktop programs on Windows using the Bash shell.
Change Your UNIX User Account
Uninstall and Reinstall the Ubuntu EnvrionmentWhen you first set up Bash, you’ll be prompted to
create a UNIX user account and set a password. You’ll 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 lxrun command or changing your default user account.
Bash will automatically reinstall an Ubuntu environment the next time you launch it, but the lxrun command
can also be used to install the Linux environment. You can write a command that automatically responds to
the questions you’re asked when installing the Linux environment, for example.After you’ve installed some
programs or changed some settings, you might want to reinstall the Ubuntu environment and get a fresh Linux
slate. You can do this with the lxrun command , which allows you to remove your installed Linux system
files and either keep or delete the user files in your home folder.
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 or server software that needs
to run in the background any time soon.