Introduction to Cygwin

Not open for further replies.


Posts: 4,909   +8
[SIZE=4]Introduction to Cygwin[/SIZE]

Cygwin is a UNIX-compatible environment that runs on Windows systems. It consists of cygwin1.dll, a library that takes POSIX calls and translates them into Win32 calls (kind of like winelib in reverse); a shell (GNU BASH, the shell used on most Linux systems, is the default); an implementation of the X Window System and, of course, GCC.

There are many reasons why you'd want to use Cygwin:

You are used to UNIX-like systems, but are forced to use Windows for some reason.

You want to compile and run *NIX software on Windows.

You are thinking of switching from Windows to a UNIX-like OS, and want to learn more about the environment you will be working in, before you actually do it.

You need an X server on Windows, and don't want to pay upwards of US$600 for one.
This FAQ will tell you how to set up Cygwin, and some of the cool things you can do with it. Please note that these instructions assume you are using Windows NT/2000/XP. The procedures are similar for Win9x, use common sense.

Installing Cygwin

Login as Administrator, or some user with Administrator privileges.

Go to

Click Install Cygwin Now to download setup.exe. Make a directory "cygwin" and put setup.exe there.

Run setup.exe

Choose "Install from Internet". You will get a dialog asking where you want to install Cygwin, who to install it for, and the default text file mode. Accept the defaults. You will then be asked about proxy settings, and then you will get a list of mirror sites. If you know which site is closest to you, use that one. If not, pick one at random and hope for the best.

You will then get a list of packages. There are tons of them, but almost all of them have descriptions. Installing everything is a safe bet if you haven't the slightest idea what this is all about.

Cygwin will install itself, and then ask if you want any shortcuts. Installation is complete.

If you get any warnings about incomplete downloads, click "retry", pick a different mirror, and then just hit "next" on the package selection screen. If it fails again, don't retry, cygwin should work just fine without it.
Now you've got a Cygwin shortcut somewhere in your start menu or desktop. When you start it, you will get a command prompt. The command prompt proto-FAQ written earlier can give you an idea of what to do here. There are a few things you should know about Cygwin's filesystem:

/ is actually C:\cygwin, or wherever you installed cygwin.

You can access the rest of your drive(s) from the /cygdrive/letter directory. For example, C:\ is /cygdrive/c, D:\ is /cygdrive/d, and so on.

/proc and /dev are present, but they aren't all that useful, since Windows just doesn't like the "everything is a file" way of doing things.

Cygwin interprets .lnk files (shortcuts) as symlinks.

Everything is case sensitive. Do not forget this.
Now, here's a few things you might want to do to get the most out of Cygwin:

Setting up X
No nVidia drivers this time around, but you DO have to reconfigure your environment a bit to make X work. In the interest of modular design, cygwin doesn't do this for you, as that would mean assuming X is installed. That is unacceptable.

Note that all of these steps are to be performed in the Cygwin shell.

vim /etc/profile

Find the PATH line. Add /usr/X11R6/bin to it. Then save and exit.

export PATH=$PATH:/usr/X11R6/bin (to make it take effect in the current session)

man XWin

Look over the command-line switches in the manpage. Decide which ones you will want to start X with.

vim /usr/X11R6/bin/ (In cygwin, is the best way to start X. The more UNIX-like "startx" command also works, but not very well.)

Find the XWin command in this script. Add the switches you decided on in 5. Also note the twm command. You will be changing that to the window manager you want when you get everything set up. Save and exit.


If all is well, a window with a stippled background (the infamous monitor-and head-exploding X stipple) and a command prompt window (an xterm) will open. This is your X server in all it's glory. If you set it to run fullscreen, then this display will cover your entire screen, instead of showing up as a window. You can get out of it with ALT-F4 (the windows way) or CTRL-ALT-BACKSPACE (the *NIX way).

At this point you might want to consider getting a more feature-rich window manager to take the place of TWM. WindowMaker and FVWM are included with Cygwin as optional packages. Almost any window manager should compile and run without much hassle. KDE 2.2 is available as well if you want that. Either way, when/if you install a new window manager, just open up /usr/X11R6/bin/ and find the twm command, and replace it with the command to run your window manager.
Making it possible to run Cygwin apps from normal command prompts and the windows GUI

Windows NT:
My Computer > Properties

Advanced tab

Environment variables button

Find the "PATH" one. Add C:\cygwin\bin to it.

Windows 9x:
Open c:\autoexec.bat

Find the PATH line. Add C:\cygwin\bin to it.

Not open for further replies.