4 Easy Ways to Run Linux and bash in Windows

Updated: Mar 16, 2019


In our new book, Cybersecurity Ops with bash, we teach readers how to leverage the command line and bash to perform security analysis, administration, and penetration testing. The power of the Linux command line and bash was once out of reach for Windows users, but that is no longer the case. Today there are two ways these tools can be run in the Windows environment: emulation, and virtualization.


The two emulation methods we will cover are:

  • Cygwin

  • Git Bash

The two virtualization methods we will cover are:

  • Windows Subsystem for Linux

  • VirtualBox and VMware


Cygwin


The Cygwin Project is one of the original ways to run Linux utilities and commands in Windows. Cygwin is an emulator that runs like an application within Windows. Because of that, it can execute common Linux utilities such as grep, as well as reach down and run Windows commands like wevtutil.


By default, Cygwin also mounts the local hard drive (c:\ on most Windows systems) which can be found under /cygdrive/c.

Cygwin can be downloaded at https://www.cygwin.com/ and is installed just like any other Windows application.


Git Bash


Git is an open source version control system designed by Linus Torvalds. When installed on Windows it comes packaged with the Git Bash Linux emulator. Git Bash is similar to Cygwin, but is lighter weight and not as extensible. Once installed, Git Bash can be launched by right-clicking in Windows Explorer and selecting Git Bash Here.

Like Cygwin, Git Bash can execute most Windows commands, and also mounts the local hard drive, which can be found at /c.

Git can be downloaded at https://git-scm.com/.


Windows Subsystem for Linux


The Windows Subsystem for Linux (WSL) was introduced with Windows 10. WSL allows you to install full Linux distributions, such as Ubuntu and Kali, within Windows. To install it:


1. Click the Windows 10 search box

2. Search for Control Panel

3. Click Programs and Features

4. Click Turn Windows features on or off

5. Check Windows Subsystem for Linux

6. Restart the system


7. Open the Windows Store


8. Search for Linux and install the distribution of your choice

For more information on installing WSL visit https://docs.microsoft.com/en-us/windows/wsl/install-win10.


Unlike Cygwin and Git Bash, WSL installs a full Linux distribution, but it is logically separated from the Windows environment. As such, you cannot run Windows commands like wevtutil from a WSL instance. Many distributions do however allow you to mount the local hard drive. In Ubuntu this is found under /mnt.


VirtualBox and VMware


The final way to run Linux in Windows is to use virtualization software such as VirtualBox or VMware. This is arguably the most powerful, but also the most complex to setup.

By using virtualization software you can install nearly any distribution of Linux desired. It also provides advanced features for creating networks of virtual machines.


VirtualBox can be found at https://www.virtualbox.org/ and VMware at https://www.vmware.com/.


Conclusion


These methods provide you the ability to run Linux in Windows using a variety of configurations. Here is a table to help you choose the best method for your particular circumstance.


75 views

© 2020 by Paul Troncone and Carl Albing