Windows 10 includes an underlying “Windows Subsystem for Linux” to run Linux applications, but it’s only accessible via the Bash shell. However, there is a way to run Linux applications without first launching a Bash window.

This is possible thanks to the bash -c command. Use it to run Linux commands via Command Prompt and PowerShell, or even create a desktop shortcut that runs a Linux command or program when launched.

Update: If you have multiple Linux environments installed, you can use the wslconfig command to choose the default Linux environment. There’s also a way to run commands in specific Linux environments.

How to Run Linux Commands in the Command Prompt or PowerShell

RELATED: How to Install and Use the Linux Bash Shell on Windows 10

Before you do any of this, you’ll need to install and set up Windows 10’s Bash shell. After you do, you can open a Command Prompt window and  run the following command to run Linux software outside a Bash window:

bash -c "command"

For example, let’s say you wanted to install the emacs package via apt-get. You’d run the following command in a Command Prompt window:

bash -c "sudo apt-get install emacs"

When you use bash -c, Windows will launch a Bash shell in the background and pass the command to it. The command will run until it’s done and then quit, along with the Bash shell. Any terminal output the current command runs will appear directly in the Command Prompt window, rather than a separate Bash shell window.

This trick also allows you to run Linux commands in PowerShell, just as you’d run a normal Windows executable. You can do this by directly running the .exe file as you would in a Command Prompt window, or via any other method for running executables in PowerShell.

bash -c "uname -a"

As with a Command Prompt window, the output of the command will appear directly in PowerShell. These methods can be used to add Linux commands to a batch file or PowerShell script, too.

How to Run Linux Commands From the Run Dialog or Start Menu

This trick also works for running commands from the Run dialog, Start menu, or any third-party application launcher.

For example, to launch vi from the Run dialog, you’d press Windows+R on your keyboard and then run the following command:

bach -c "vi"

The vi text editor will appear in its own window.

This also works for the Start menu, so you can type the same command directly into the Start menu and press Enter to run it as a command.

How to Run Linux Commands with a Desktop Shortcut

The bash -c command also makes it possible to launch Linux applications via a desktop shortcut. For example, let’s say you wanted to launch the vi text editor through a desktop shortcut. You’d right-click the desktop, point to New > New Shortcut, and enter the following target:

bash -c "vi"

You can now save the shortcut and it will launch vi when you double-click it.

RELATED: How to Run Graphical Linux Desktop Applications from Windows 10's Bash Shell

Interestingly enough, this trick also works for launching graphical Linux applications from a desktop shortcut. Install an X server and set up graphical Linux desktop applications. You should be able to create shortcuts to launch them directly.

However, you’d have to launch them like this:

bash -c "DISPLAY=:0 command"

While you can launch Bash commands from elsewhere in Windows, there’s no way to run Windows software or executables directly from a Bash shell window.

Profile Photo for Chris Hoffman Chris Hoffman
Chris Hoffman is Editor-in-Chief of How-To Geek. He's written about technology for over a decade and was a PCWorld columnist for two years. Chris has written for The New York Times and Reader's Digest, been interviewed as a technology expert on TV stations like Miami's NBC 6, and had his work covered by news outlets like the BBC. Since 2011, Chris has written over 2,000 articles that have been read more than one billion times---and that's just here at How-To Geek.
Read Full Bio »