Cygwin Cheat Sheet

Installing Cygwin

Working on embedded software under Windows often requires the Cygwin environment be installed so that a number of standard UNIX utilities are available for this effort. One of the most useful tools supplied in Cygwin is the bash shell which is a far more useful command line environment than the standard Command Prompt supplied with Windows. The GNU compiler collection (gcc) is also oftentimes used as the compiler front-end for various microcontrollers. Cygwin gives you all of this, plus a lot more.

Cygwin also supplies a Windows DLL called cygwin1.dll which is a library of routines that provide POSIX.1 emulation. This DLL contains all the standard UNIX system calls such as fopen, fprintf, and so on. Armed with these functions, a UNIX-based program can be recompiled against the Cygwin DLL and then run on Windows.

This emulation API is what allows the UNIX utilities to be easily ported to run under Windows. The number of Cygwin packages available is many and varied. The standard UNIX tools such as ls, grep, and all the others are available. The full list of packages can be found here:

Compilers, libraries, make tools, and the rest of the tools that make up a robust toolchain are just a few of the tools available to assist you in your embedded software development efforts. Cygwin also provides the newlib ANSI C library instead of the glibc ANSI C library; newlib consists of the libc and libm C libraries and has typically been used for embedded software development.

Installing Cygwin on Windows

First, decide on a directory to use to store the Cygwin source files in as well as a directory to actually install Cygwin into (this latter directory is called the Cygin root directory because it is where your / root directory will point to in the Cygwin environment). I like to store the Cygwin source in d:\cygwin-source and install Cygwin to the c:\cygwin directory.

    1. Choose a directory to use as your Cygwin source directory and create it.

    2. Choose a directory to use as your Cygwin root directory and create it.

    3. Go to the Cygwin home page ( and click on the Install or update now link. This will download the setup.exe program; place it in your Cygwin source directory you created in Step 1.

    4. Now run the setup.exe program. In the first window—which is titled Cygwin Net Release Setup Program—click the Next button.

    5. In the Choose A Download Source window, select the Install from Internet option, then click the Next button.

    6. In the Select Root Install Directory window, browse to the directory you created in Step 2 to install Cygwin into.

    7. Make sure that the All Users and Unix/binary options are chosen, then click the Next button.

    8. Browse to the Cygwin source directory you created in Step 1, then click the Next button.

    9. In the Select Your Internet Connection window, select the option that represents the type of Internet connection you have, then click the Next button.

    10. In the Choose A Download Site window, select a download site to obtain all the Cygwin files from (e.g.,, then click the Next button. A list telling you where each download site is geographically located is available here:


    12. A progress window will appear. Behind the scenes, the program will create a subdirectory under the Cygwin source directory (created in Step 1) that relates to the name of the download site you chose in Step 10. For example, something like this:


    14. At this point there will now be a file called setup.ini in this subdirectory, the contents of which are displayed in a GUI in the window titled Select Packages (this window is also known as the chooser window, since you choose which packages to be installed here). There are four radio buttons which filter the versions of the packages that are shown in the main part of the window. The options are:

        • Keep: Show the version of each package that is currently installed on the system.

        • Prev: Select the previous version of each package.

        • Curr: Select the current version of each package.

        • Exp: Select the experimentatl version of each package.

    15. Select one of these four options to select the version of each package that you would like to install; you will most likely want to use the Curr option in order to have the currently released version of each package installed.

    16. The second control on this window, controlled with the View button, toggles the information in the main part of the window through the following views:

        • Category: Display all of the packages, organized by categories.

        • Full: Show all of the available packages, allowing you to choose which ones you wish to have installed.

        • Partial: Shows only the packages that are to be installed, upgraded, or removed. It is useful to select this view just prior to clicking the Next button so that you can review the actions the program are about to take are what you want.

        • Up To Date: Displays the packages that are already at their most currently released version.

        • Not Installed: Displays only the packages that are not currently installed on the system and which have not be selected for installation.

    17. The first time that you install Cygwin you may want to simply keep the package versions at their default selections, so just click the Next button in this window to install the packages shown.

    18. The program will download each package selected in the previous window, placing them in the Cygwin source directory (from Step 1), and installing them into the Cygwin root directory (from Step 2). It may take a few minutes or some number of hours for this step to complete depending upon how many packages you selected for installation.

    19. The final window—titled Create Icons—allows you to place a Cygwin icon on your desktop and/or in your start menu. Make your choices, then click the Finish button.

One-Time Configuration Step

Now that Cygwin is installed, bring up a bash window by clicking the Cygwin icon that has been installed. You will see two messages about mkpasswd and mkgroup needing to be run to get the Windows users and groups defined. Before you can run the two commands shown, you first need to make the group file writable. In the bash window, go to the etc directory:

cd /etc

Now make the group file writable:

chmod +w group

And run the two commands shown in the message:

mkpasswd -l -d > /etc/passwd

mkgroup -l -d > /etc/group

Finally, set the group file back to read-only:

chmod -w group

Now close the bash window and open another one; the message about the passwd and group files should no longer appear.

You are now ready to use Cygwin.

Maintaining Your Cygwin Installation

While you do not have to keep the Cygwin source directory on your system, it can be very handy should you need to reinstall Cygwin or install Cygwin on an additional system.

Related Posts:

    • Configuring Cygwin

[TO-DO: Upgrading your installed Cygwin packages.]

[TO-DO: Installing an additional Cygwin package.]