How to get a bash shell on Windows 7 & 8

22/06/2018

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


%d bloggers like this: