Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Cygwin mini Tutorial

Contents

Cygwin is free software that provides a Unix-like environment and software tool set to users of any modern version of MS-Windows for x86 CPUs (NT/2000/XP/Vista) and (for the time being, at least) some obsolete versions (95/98/ME) as well. Cygwin consists of a Unix system call emulation library, cygwin1.dll, together with a vast set of GNU and other free software applications organized into a large number of optional packages. Among these packages are high-quality compilers and other software development tools, a complete X11 development toolkit, GNU emacs, TeX and LaTeX, OpenSSH (client and server), and much more.

Cygwin does not provide a means for running GNU/Linux or other Unix binary executables under MS-Windows. In order to run such software using Cygwin, that software must be compiled from its sources. Cygwin provides all of the components needed to do this in most cases; most POSIX-compliant software, including X11 applications, can easily be ported to MS-Windows using Cygwin.

For general assistance on Cygwin beyond what is included here, please use the resources listed at the end of the page.

Installing Cygwin

Overview

Installing Cygwin begins with downloading and running the Cygwin installer (setup.exe), which is a small application that allows you to choose:

as well as a few other installation options. Cygwin packages consist of bzip2-compressed tar (.tar.bz2) archives. The installer downloads these from the mirror you have chosen into a temporary directory, validates them by computing their MD5 sums, and then unpacks them into the root directory you have chosen.

If you have at least 5 Gb free disk space (half of which can be reclaimed after installation), you may choose to perform a full installation of Cygwin with all of its optional packages. This choice is recommended for those who prefer to work in a Unix or GNU/Linux environment but who are constrained to work under MS-Windows. A full installation provides a large subset of the software provided as standard components of a typical GNU/Linux distribution. Allow at least an hour to perform a full installation if you have a fast Internet connection, more otherwise.

If you wish only to compile and use existing software under MS-Windows, you may choose a custom installation of Cygwin, consisting of the Base package and a few optional packages listed below; this choice requires less than 1 Gb, and proportionately less time than a full installation. A minimal installation may be upgraded easily at a later time, by following the same procedure as for initial installation. Packages that have previously been installed will not be changed unless newer versions have become available and you choose to install them.

When the installation is complete, the Cygwin root directory will resemble that of a typical Unix or GNU/Linux system, with subdirectories bin  (applications and DLLs), etc  (configuration files), home  (containing a subdirectory for each Windows user registered on your system), lib  (static libraries), tmp  (temporary files), usr  (containing additional software), var  (log files), and (depending on the optional packages you choose) perhaps other directories as well. The later sections of this page (Using Cygwin and Using Cygwin/X) describe how to access the software once it has been installed.

Prerequisites

  1. Make sure that you are using a version of Windows supported by Cygwin, and that you have sufficient disk space and time available for the installation, as indicated above.
  2. If your Windows login name contains a space character, consider changing it or creating a separate login for use with Cygwin. The Cygwin installer names your home directory according to your Windows login name. It is usually possible to work around problems caused by directory or file names that contain spaces, but they will be a constant irritation; it's better to avoid them.
  3. Some virus scanners may interfere with Cygwin installation. If you encounter problems, consider disabling your virus scanner during Cygwin installation and re-enabling it afterwards.

Cygwin 1.5.x vs. Cygwin 1.7.x

As of early 2009, Cygwin 1.7 is in beta testing; see the Cygwin web site for the most recent information if you wish to participate in the beta test. The installation procedure for Cygwin 1.7 has not changed significantly from the procedure described below for Cygwin 1.5 (the current release). MS-Windows 95, 98, and ME are incompatible with Cygwin 1.7; if you must use one of these older versions of Windows, install Cygwin 1.5.

Running the Cygwin installer

      Cygwin!
    Install
    Cygwin
    now
     
  1. Click on the "Install Cygwin now" icon at right (or do so on the Cygwin web site). Save the link (setup.exe) to your desktop, then double-click on the saved icon to begin installation.

     
  2. A window titled Cygwin Net Release Setup Program appears. Click Next to get started.
    [Cygwin installer]
     
  3. Choose A Download Source: Accept the default ("Install from Internet") and click Next.
    [Choose A Download Source]
    Choosing the default "Install from Internet" causes the files you will choose in a later step to be downloaded first and then validated and installed. The other choices allow you to perform this procedure in two steps.

     
  4. Select Root Install Directory: Accept the defaults ("C:/cygwin", All Users, Unix) and click Next.
    [Select Root Install Directory]
    Important: The default root directory for Cygwin applications is C:\cygwin.  All files installed by the Cygwin installer go into this directory; to uninstall Cygwin at a later date, simply remove this directory and all of its contents.

    Don't change the default text file type ("Unix").

  5. Select Local Package Directory: Accept the default or change it to any temporary directory of your choice, but make a note of it.
    [Select Local Package Directory]
    After the installation is complete, you may delete the .tar.gz  package files that will have been written there. If you have chosen a full installation, these files may occupy over a gigabyte, and they are no longer needed once their contents have been installed. If you plan to install Cygwin on another PC, however, you may be able to save time by copying the local package directory and the Cygwin installer to the second PC; follow these instructions to install Cygwin on the second PC, but choose "Install from Local Directory" in step 3.
     
  6. Select Your Internet Connection: The default should be correct for most users. Change it only if you encounter problems.
    [Cygwin installer]
     
  7. Choose A Download Site: Select a nearby mirror site from which to download the Cygwin packages. Speeds may vary considerably from site to site.
    [Cygwin installer]
    At this time, the installer downloads a list of available packages from the site you have chosen. Normally, this takes only a few seconds; if there is a lengthy pause, you may wish to start over and choose a different mirror site.

     
  8. Select Packages: If you wish to do a full installation, click on the rotating selector next to "All" (at the top of the Category list) so that the indicator to its right changes from "Default" to "Install". Click Next and skip ahead to step 10.
    [Cygwin installer]
     
  9. If you wish to do a custom installation, click the View button so that the indicator to its right changes from "Category" to "Full".
    [Cygwin installer]
    You may resize the dialog box as needed until the package names are visible.

    To select a package for installation, click on its rotating selector (in the New column) to cycle through the available choices until a version number appears. In most cases, you should choose the highest version number from those that are available (this is usually the first alternative offered).
    [Cygwin installer]
    In the example below, the sunrpc package, version 4.0-2, has been selected for installation. Note that the entry in the Bin? (Binary) column changes from n/a to a checked box when you select a numbered version of the package. Leave this box checked. The entry in the Src? (Source) column changes from n/a to an unchecked box, which you may check if you would also like to download the sources for the package.
    [Cygwin installer]
    If you plan to use PhysioToolkit software, be sure to choose at least the following packages for installation:


    (The categories to which each package belongs are shown following the package names above, for reference.) You may choose any other desired packages, either at this time or later on (by running Cygwin setup again). The Cygwin installer will automatically download any additional packages needed to satisfy dependencies of those you select. When you have completed your selections, click Next.

     
  10. The downloading process begins once the packages have been selected. The installer indicates its progress.
    [Cygwin installer]
     

    Be patient; the downloading and installation process may take an hour or more (depending not only on the speed of your Internet connection, but also on the load on the Cygwin mirror site from which you are downloading).

     

  11. Once all selected package files have been downloaded and checked, they are unpacked into the Cygwin root install directory.
    [Cygwin installer]
     
  12. Following package installation, any installation-dependent configuration scripts are run to complete the setup process. (There may be lengthy pauses during this step, without any indication of progress. Be patient!)
    [Cygwin installer]
     
  13. Create Icons: Unless these icons already exist from a previous Cygwin installation, make sure the boxes are checked and click Finish.
    [Cygwin installer]
    That's all!

You may always run Cygwin setup again to obtain additional or updated packages without reinstalling packages that remain current; if you do this, be sure to shut down any running Cygwin applications first.

Using Cygwin

As noted, Cygwin provides a Unix-like environment under Windows. The installation directory (by default, c:\cygwin) is the root of the Unix-like file system, which contains bin, etc, home, tmp, and usr  directories as would be found on a GNU/Linux or other Unix system. Within home  will be one or more subdirectories, each allocated to a Windows user. Cygwin desktop icon

To begin, click on the Cygwin desktop icon, or choose the Cygwin entry from your start menu, to open a Cygwin terminal window. Within this window, the GNU bash  shell is running, with POSIX syntax (directory separators are '/', not '\'). Initially, the current (working) directory is /home/user, where user  is your Windows login name. Don't use this directory if your Windows login name contains a space; make another and use that one instead, e.g., by typing these commands at the bash  prompt:

    mkdir /home/bob
    echo "export HOME=/home/bob" >>.bashrc
    echo "export HOME=/home/bob" >>.bash_profile
    cp .bashrc .bash_profile /home/bob
    echo "cd" >>.bashrc
Close your Cygwin terminal window and open another one; your current directory should now be /home/bob  (or whatever you chose to call it). See the Cygwin FAQ (look for "My Windows logon name has a space in it") for other solutions to this common problem.

Finding Cygwin files with Windows applications, and vice versa

Pathnames of files are often confusing to new Cygwin users. A pathname is simply a set of directions for finding a file. An absolute pathname begins at a fixed location (the root of the file system). The confusion arises because native Windows programs use c:\  as their root, and Cygwin programs use c:\cygwin  (unless you chose some other place to install Cygwin).

This means, for example, that a file created using a Cygwin program as /home/bob/foo.txt  can be read using a native Windows program as c:\cygwin\home\bob\foo.txt  (the two pathnames refer to the same disk file).

If you need to use a Cygwin program to read or write a file located outside of c:\cygwin, you can use a pathname beginning with /cygdrive/c/  for this purpose. For example, a native Windows file called c:\My Documents\hello.c  can be found by a Cygwin program at /cygdrive/c/My\ Documents/hello.c  (note how the space character in "My Documents" must be prefixed by "\" to force it to be treated as part of the pathname). If you have a Windows d: drive, use /cygdrive/d/  in the same way to access its contents from Cygwin programs.

Unix/Linux files occasionally have names that differ only in case (a frequent example is makefile  and Makefile). Be careful: although Windows does preserve the original case of characters in filenames, it ignores case when looking for matches to file names. So, for example, if you write a file called baz.zip  and then another called Baz.zip, the first one will be overwritten. This behavior might be no surprise to Windows users, but it may be unexpected to Unix users.

Using Cygwin/X

The X Window System, version 11 (often "X11", or simply "X") is the standard graphical environment under Unix and GNU/Linux; it is also available for other platforms, including Mac OS X and MS-Windows. X applications ("clients") exchange data with an X server (another application). The X server receives and interprets instructions from the clients for displaying the clients' windows, and it collects and transmits keyboard and mouse input events to the clients. The xorg  packages available with Cygwin (collectively, "Cygwin/X") provide a high-quality X server (XWin), a large set of standard X clients, and a complete set of development tools that can be used to compile X clients that run under MS-Windows.

Important: X clients cannot run unless they can connect to a running X server. The X server must be started first. When you use Cygwin/X, the X server runs on your PC, under MS-Windows. Once the X server is running, you can launch and interact with X clients on your PC or on any other networked computer (which can be running MS-Windows, GNU/Linux, Mac OS X, Unix, or any other OS that can run X client software).

The X server, XWin, can be launched in several ways. One of these is by running c:\cygwin\usr\X11R6\bin\startxwin.bat  (you may wish to create a desktop shortcut to this batch file so that you can launch the X server by clicking on its icon). Another way to launch the X server is by running the command startx  in a Cygwin window.

When you launch the X server, it starts an xterm  (terminal emulator) client:
[xterm]
Within this window, just as in a Cygwin terminal window, you are running the GNU bash  shell. An important difference is that you can launch other X clients from an xterm  without additional preparation.

You can access xterm's menus by pressing and holding the Ctrl key while clicking the left, middle, or right mouse buttons. Use these menus to enable the scrollbar (as shown in the screen shot above) or to change the character size, among other possibilities.

While the X server is running, its icon ("X") appears in the Windows system tray (see above). You can click on this icon to force the X server to exit, but doing so will also force any X clients to exit; normally you should exit from all X clients before stopping the server.

Since the X server is a complete window system, it has a "root" (background) window on which X clients' windows are displayed. By default, XWin runs in "rootless" mode, in which its root window is invisible, allowing the MS-Windows desktop and application windows to be visible, and allowing the X clients' windows to be moved, resized, closed, and reopened using the same methods as for native MS-Windows applications.

Further Reading

Readers who are familiar with GNU/Linux or Unix may not need much more information than what is given above to begin using Cygwin productively. The environment is so Unix-like that it's easy to forget that it is all running under MS-Windows. The Cygwin project documentation highlights the important differences between Cygwin and other Unix(-like) environments.

Those who are new to Unix may find the additional resources listed below to be helpful while they are becoming familiar with the Unix way of doing things, which is quite different from the MS-Windows model. Almost anything you learn while using Cygwin is directly transferrable to GNU/Linux. If your experience encourages you to make the leap to GNU/Linux, you might want to start with a live CD distribution such as Knoppix, which allows you to run a full GNU/Linux distribution without writing anything to your hard disk.



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: March 12, 2019