Installing Cygwin on a Windows PC. User Level: Beginner

Contents

  1. Purpose
  2. Requirements
  3. Introduction
  4. Installing Cygwin and SSH
  5. Post Installation
    1. SSH to the Computer Science Lab Machines
    2. Setting the Terminal Type
  6. Installing More Applications
  7. Other Resources

Purpose

This tutorial provides step-by-step instructions on installing Cygwin on a Windows PC, with an extra step to install ssh. The post installation section includes example usage of ssh and instructions on adding new applications.

Requirements

In order to install Cygwin you will need:
  1. Either Windows 95, 98, ME, NT, 2000, or XP. Cygwin does not run under Windows 3.11.
  2. 45 MB free disk space.
  3. An internet connection.

Introduction

After using the UNIX systems in the Computer Science labs most students want or need a way to run UNIX programs on their own machine. Some want the UNIX tools that do not exist in Windows (e.g. bash, tcsh, less, grep, Vim, Emacs, etc.). Others, tired of the trek to the labs, want to complete their course work at home. Their are a few ways to install a UNIX environment on your home system.
  1. Install one of the UNIX like operating systems: FreeBSD, Linux, OpenBSD, NetBSD, etc.
    • Pros
      • Complete UNIX environment running natively on your computer without the need of another operating system.
      • They tend to be more stable than Windows 95/98/Me.
    • Cons
      • Only for an expert level computer user.
      • Normally, computers come with their entire hard disk devoted to Windows. Installing one of these UNIXs requires reformatting and partitioning the harddrive to create space for Windows and UNIX.
      • With the extra power of these UNIXs comes a somewhat less user friendly experience than Windows. However, there are some that attempt to be as friendly as Windows, e.g. RedHat Linux.
  2. Install the Cygwin UNIX environment under Windows 95/98/Me/2000/XP.
    • Pros
      • This is the best option for most users.
      • Gain access to the UNIX tools you use.
      • Runs under Windows and does not require harddisk repartitioning.
      • Can add the X environment to display graphical UNIX programs running on your machine and remotely running from the Computer Science labs.
    • Cons
      • Some UNIX tools may not yet be ported to the Cygwin environment.
  3. If you have Mac OS X Congratuations! you already have a UNIX environment. Click the Terminal icon and get started. If you have an older Mac OS you can install a UNIX like operating system. See the comment on that above.

Installing Cygwin

  1. Click here: http://www.cygwin.com to get the setup program. The link will open a new window.
    In the Cygwin webpage window click the Cygwin icon that says "Install now!" and download the setup program to your Desktop, or a folder you will remember.

    The icon looks like:

    Cygwin install now!
  2. Find the setup program you just downloaded and double click it.

    The setup programs icon will look like: Cygwin setup icon

  3. Once the setup program launches you will see setup screen. Click the Next button.
    Cygwin Setup Screen 1
  4. We will use the default Install from the Internet so click Next.
    Cygwin Setup Screen 2
  5. By default Cygwin will install in C:\cygwin. This is fine. We will use the default options in all the boxes so click Next
    Cygwin Setup Screen 3
  6. Cygwin stores setup files in a temporary directory. We will use the default directory so click Next. After setup is complete you may delete the directory Cygwin creates under the directory listed to save disk space.
    Cygwin Setup Screen 4
  7. If you don't know what type of internet connection you have, or you live in the dorms, leave the default Direct Connection selected. Click Next
    Cygwin Setup Screen 5
  8. Between the last step and this step a screen will briefly flash, this is normal, it is downloading a list of Cygwin download sites.
    In this step you will select a download site to get Cygwin from. A fast site near RIT is http://ftp.lug.udel.edu find it in the scroll box by scrolling down. Then select it with the curser, then click Next
    Cygwin Setup Screen 6
  9. This screen briefly flashes depending on how fast your internet connection is. Do NOT press anything. it will automatically go to the next screen when finished.
    Cygwin Setup Screen 7
  10. The select packages screen shows a tree of packages by category that you can install. Most applications you need are installed by default, however, ssh is not.
    The way applciations are listed can be changed by pressing the View button. Each time you press the view button it moves to the next view. There are three different views:
    1. Category A tree structure with applications placed under the category they belong to. For example, emacs is under Editors.
    2. Full A detailed listing of all packages in alphabetical order. Under this view you can tell the current version number of a package if it is installed. In addtion, in the New column it will tell you what will happen to this package during setup. Most commonly you will see:
      • Skip Nothing will change with this package.
      • Keep The package is installed and it will stay installed.
      • Install The package will be installed by setup.
      • Unistall The pacakge will be removed by setup.
      • [version number] You may see a version number of a package. This indicates this version will be installed. Sometimes multiple versions of the same package will be availabe.
      By pressing the rotating arrow symbol, Rotating Arrow Symbol, you can alternate between the different choices. For example, if it says Skip and you click the icon it will then change to a version number or the word Install both indicating the pacakge will be isntalled by setup. You can click a few more times on the icon, Rotating Arrow Symbol, to go back to skip. We will do this shortly to install ssh.
    3. Partial A listing of packages that will be installed, uninstalled, and updated.
    Because ssh is not installed by default in the next two steps we will select it.
    Cygwin Setup Screen 8
  11. We will now select the ssh package to install.
    If you have not already done so, click the View button to show the Full listing.
    Scroll down until you see openssh: The OpenSSH server and client programs. Some of the text may be cut off by the window. There is only one openssh; it does not matter if you do not see the full description.
    Notice in the New column openssh will be Skipped.
    Click the rotating arrow symbol once,Rotating Arrow Symbol. This will show the version number of openssh that will be installed.
    Go down to the next step to see the result.
    Cygwin Setup SSH 1
  12. Now that you have selected openssh to intall you will notice that openssl will also install. This occurs because openssh is dependent on openssl. You do not need to worry about dependences because Cygwin will automatically install packages required by other packages.
    Now we are ready to install Cygwin. Click Next
    Cygwin Setup SSH 2
  13. Depending on how fast your internet connection is this may take a while.
    Cygwin Setup Screen 10
  14. At this point Cygwin has downloaded all the necessary files it needs. Keep the Creat icon on Desktop box checked so a Cygwin shortcut will be placed on the Desktop. This may be deleted later.
    You may also want to check the Add icon to Start Menu to access Cygwin through the Start Menu.
    Click Finish
    A few black screens will pop up. This is normal as Cygwin is configuring itself. It will automatically go to the next screen.
    Cygwin Setup Screen 11
  15. Congratulations! You are done. Click Ok to exit the setup program.
    Cygwin Setup Screen 12

Post Installation

Now that Cygwin is installed lets try a few commands.
To launch Cygwin double click the Cygwin icon on your Desktop, Cygwin Icon. The Cygwin shell will appear.
By default Cygwin uses the bash shell. The prompt is split into two lines. The top line shows that the user Sam is working on the computer ARSENIC in his home directory ~.
Try a few UNIX commands in the cygwin shell, e.g., ls, mkdir, rmdir, etc, then move to the next step.
Note: In cygwin the more command does not exist by default, use the less command which does the same thing instead.
Cygwin Shell 1

SSH to the Computer Science Lab Machines

Now we ssh into a Computer Science machine. At the prompt type:
ssh <username>@<computer address>
replace <username> with your username and <computer address> with the address of a CS lab computer.

Note on the Computer Science Lab computer addresses. You can ssh into any of the machines in the CSL and ICLs using the machine name follwed by cs.rit.edu. For example, to ssh into newyork use the address newyork.cs.rit.edu.

When you ssh into a machine ssh checks its authenticity, meaning that it wants to make sure the machine you are sshing into is the machine you are truely sshing into. The first time you ssh into a machine ssh has nothing to check the authenticity of a machine against, except for you. This is why on the first time you ssh into a machine it asks if you are sure you want to do this. When you type yes ssh will store information about the machine so it can check authenticity without prompting you next time.

After you type yes you are prompted for a password. Type your computer science account password, it will not appear on the screen.
Cygwin Shell 2

Setting the Terminal Type

At this point you have the same shell as you would when logging in directly at a lab machine. You may start any program that operates within a shell, e.g. ls, cp, Emacs, Vim; however, applications that require a graphical interface, e.g. Netscape and acroread will return an error. In a later tutorial we will setup an X server on your machine so graphical applications can run remotely.
Notice the error message:

Type cygwin unkown
Terminal type = cygwin


Cygwin Shell 3
This occurs because Cygwin told the shell it uses the cygwin terminal protocal to render data, and the computer science machines are not setup to work with this protocal. This causes problems with certain applications which rely on a known terminal protocol. For example, if you type emacs you will get a long error message, which basically means emacs is confused. To fix this we need to set the terminal type to a protocal the CS systems recognize.

At the prompt type: setenv TERM ansi
This will set the terminal protocal to ansi, which is compatiable with the cygwin protocal, and known by the CS systems.
Now try emacs again.

Unless you want to set the TERM type manually every time you ssh into the systems we need a more permanent solution.

  1. In your home directory type: emacs .login
    This will open the .login file which is executed everytime you login to the systems.
  2. Under the line: source /usr/local/lib/config/Login
    Enter this code:
    if( $TERM == "cygwin" ) then
    setenv TERM ansi
    endif
  3. Save and exit.
Now when you ssh from cygwin the terminal will be set to a protocal the CS systems know. Note: that the error message will still appear because .login is executed after the terminal type is checked, however, emacs and other applications will now work correctly.

To exit from the computer science machine type: logout

Installing More Applications

There are generally three ways to install an application under the Cygwin environment.
  1. Use the Setup program and select the packages to install.

    This is the easiest and recomended method if the application is avaiable under Setup.

  2. Download a the applications binary and install it in your path.

    This is the second easiest way, however, care must be taken to get all the files the binary depends upon, and binaries are not always available.

  3. Download the source code, compile, and install it yourself.

    Occasionally an application will not be distributed through the Setup program or as a binary file. But availabe as source code. To compile it you need the correct compiler and all dependent packages. These installations range from easy to very difficult depending on the how much effort the distributer spends on packaging the application.

We will use the Setup program to install man, Emacs, and Vim. You are encouraged to look through the packages availble for other applications you may like.

Note: To install Emacs, man, and Vim as detailed below you need atleast 51 MB of free space.

  1. If you deleted the Setup program that was used to install Cygwin, or can't find it, download it again from http://www.cygwin.com. Click here to go back to the installation step detailing it's download.

    When you have the Setup program double click it.

  2. Click Next until you see the Select Packages screen.

    Then click View to get the Full view.
  3. In the full view scroll down until you see Emacs and Click on the rotating arrow symbol, Rotating Arrow Icon, to select it for installation, the same we selected openssh for installation in the Installing Cygwin section.
  4. Now find man and Vim. Click on their rotating arrows, Rotating Arrow Icon to intall them.
  5. To view a list of all the applications that will be intalled click View for the Partial view. You may have more applications shown because Cygwin will automatically update to new versions of applications when availabe each time you go through Setup. It is a good idea to go through setup occasionally to keep your system up-to-date.
    Partial Package View
  6. Once you have selected all the applications you want to install click Next. The download progress screen will appear. This may take a while depending on your internet connection speed.
  7. Cygwin will then prompt if you want to create icons.
    Click Finish
  8. A few black screens will pop up while Cygwin configures the new applications.
    When the Installation Complete window appears click Ok
  9. The applications are installed. You may now use them in the Cygwin shell. Repeat the process for other appliations you want to install.

Other Resources

Cygwin User Manual http://cygwin.com/cygwin-ug-net/cygwin-ug-net.html
Cygwin project homepage http://www.cygwin.com
Dictionary of Computer Related Terms http://whatis.techtarget.com/
FreeBSD http://www.freebsd.org
Linux http://www.linux.org
OpenBSD http://www.openbsd.org

Last upadated September 25, 2002.
This tutorial was created by Samuel Inverso using Vim.