Getting bash for Windows

Problem

You want to get bash for your Windows system, or you want to make sure you have the latest version.

Solution

Use Cygwin.

Download http://www.cygwin.com/setup.exe and run it. Follow the prompts and choose the packages to install, including bash, which is located in the shells category and is selected by default. As of early 2007, bash-3.1-6 and 3.2.9-11 are available.

Once Cygwin is installed, you will have to configure it. See the User Guide at http://cygwin.com/cygwin-ug-net.

Discussion

From the Cygwin site:

What Is Cygwin

Cygwin is a Linux-like environment for Windows. It consists of two parts:

  • A DLL (cygwin1.dll), which acts as a Linux API emulation layer providing substantial Linux API functionality.

  • A collection of tools, which provide Linux look and feel.

    The Cygwin DLL works with all non-beta, non “release candidate,” x86 32-bit versions of Windows since Windows 95, with the exception of Windows CE.

    What Isn’t Cygwin

  • Cygwin is not a way to run native Linux apps on Windows. You have to rebuild your application from source if you want to get it running on Windows.

  • Cygwin is not a way to magically make native Windows apps aware of Unix functionality (e.g., signals, ptys). Again, you need to build your apps from source if you want to take advantage of Cygwin functionality.

Cygwin is a true Unix-like environment running on top of Windows. It is an excellent tool, but sometimes it might be overkill. For Windows native binaries of the GNU Text Utils (not including bash), see http://unxutils.sourceforge.net/.

Microsoft Services for Unix (http://www.microsoft.com/windowsserversystem/sfu/default.mspx) may also be of interest, but note that it is not under active development anymore, though it will be supported until at least 2011 (http://www.eweek.com/article2/0,1895,1855274,00.asp).

For powerful character-based and GUI command-line shells with a more consistent interface, but a DOS/Windows flavor, see http://jpsoft.com/. None of the authors are affiliated with this company, but one is a long-time satisfied user.

Get bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.