How to get a bash shell on Windows 7 & 8

Windows 10 has a built-in bash shell. I use Windows 7 and 8.1 so I was dead jealous. But I’m also an inveterate  googler, so I googled “bash windows” and found two different ways to run a bash shell on the versions of  Windows that I use: git-bash and MSYS2.

Git-bash is part of Git for Windows (“We bring the awesome Git SCM to  Windows”); MSYS2 is “a software distro and building platform for Windows” based  on Cygwin but because it is just providing a CLI (no X-server, no GUI) it is fast enough and not so buggy. Both use the MinGW  terminal, and both provide a pretty full bash environment. They were made so developers can work on Windows apps but retain the *nix-like environment.

git-bash

git-bash MINGW64 terminal

MSYS2 uses the pacman package manager, and has software repos so users can install extra packages (eg  openssh). Git-bash doesn’t provide extra installation as such: but as it runs Windows .exe apps, it is  possible to install .exes and, by placing them strategically you can run them in the terminal window – I  have so far been able to install nmap and wget to run on the command line. To get wget on git-bash, I  downloaded the standalone wget executable and placed it on the $PATH. To get nmap to work, I edited $PATH  so it included /c/Program Files (x86)/Nmap.

msys2-bash-terminal

The MSYS2 terminal

I haven’t decided which one I prefer – I’m currently running them side-by-side. One bugbear with git-bash  is that to run python the user has to prefix it with “winpty”. Winpty is “a Windows software package providing an interface similar to a  Unix pty-Master for communicating with Windows console programs”. Interestingly it is described as a tool  for Cygwin and MSYS2, but it is not needed for MSYS2 to run python; just git-bash (well, for python anyway – maybe I just haven’t yet come across a need for it in MSYS2).

Has anyone else here tried these? Any other ways to run a *nix shell on Windows?  Let us know what you think!

 bmc-orange

3 Responses to How to get a bash shell on Windows 7 & 8

  1. Why wouldn’t you just use Cygwin?

    • Martin X says:

      Because I don’t need an X-server, GUI, I’m not running any *nix apps other than bash and a few other cli programs in the terminal. And because Cygwin is a monster that I don’t want scurrying around in my computers, messing up dlls and whatever else it can get its viral tentacles on. Cygwin? Yuck! I tried it, didn’t like it, and now I use VirtualBox when I need to do some Linuxing. But I also like having bash in my winders OS environment. You ought to try it sometime.

  2. More Bonuses

    blog topic

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: