Sunday, May 10, 2009

Cygwin - a Unix Environment and Shell on Windows

If your daily routine means that you spend much of your time behind a Windows system, yet you love the power and flexibility of a Unix-based environment, it might be frustrating not to have access to the tools and environment that you want.

Alternatively, you might want to compile some Linux/Unix software, so that it can run natively under Windows.

Cygwin is a Linux-style environment for Windows, that gives you a set of libraries, a full Linux-style command line and a package manager so you can install many of the Unix programs you might be familiar with.

I thought I would take a look at Cygwin's latest release and show you how to install it and get up and running.

First of all, head on over to the site and download setup.exe. This is the main installer/package manager for Cygwin and by default you use it to do an internet-based install, i.e. the setup program itself will download the packages.

Downloaded setup.exe file

Cygwin Installer

Once the installer is up and running, click Next to bypass the initial welcome screen. You will be given several options on how you want to obtain packages. In most cases, Install from Internet is fine here.

Next, choose the directory to install Cygwin to on your Windows machine. This directory will become your root (/) from within the Cygwin shell.

Choose Cygwin directory

On the next screen, choose the temporary folder where packages will be downloaded before they are installed into Cygwin. If you want, you can use a Windows temporary folder, but if you want to keep the source packages files around so you don't have to redownload later, make it somewhere permanent.

Again, click the old Next button and choose whether you need to use a proxy. In most home computer situations, leave the defaults intact and move on.

The Installer will at this point go off and retrieve a list of the different download sites, or mirrors, available to you. Choose one geographically close to you in preference, but any of them should be fine.

Cygwin Select Packages

Here, you need to choose the packages that you want to install. You can just leave this all as it is and move on, but if you want to install additional packages into Cygwin, follow these steps.

The categories can be either left at the Default setting, or you can choose to Install or Uninstall whole categories by clicking on the 'recycling' icon next to them (and the word 'Default').

For individual packages, expand a category and find the package you want. To install or uninstall it, add a check under the 'Binary' and/or 'Source' columns to grab what you want.

Once you're done choosing packages, click Next yet again to move on. You can always come back to this stage later by re-running the installer to add or remove packages.

Cygwin Download and Installation

Download and installation now takes place. Depending on the speed of your machine and how much you've asked to download, this could take a while.

Once the installation is finished, pick your Desktop and Start menu shortcut options and Finish.

Finally - that's the installation done! You can access Cygwin through the shortcuts you just made, or by browsing to the directory you installed it in and launching cygwin.bat.

You will be presented with a bash shell, just as on Linux, and all of the Cygwin packages you installed should now be available for use.

Cygwin shell

You can also access Windows programs and files through /cygdrive/[Windows drive letter].

And there you have it - a Linux compatible environment for your Windows machine. Cygwin isn't really for the faint hearted, or those without Linux/Unix CLI experience, but it is a very powerful platform to bringing many features of the Unix platform to a Windows machine in a native way.

You can even run X on it.

No comments: