Member Sign In
Not a member?

A Wired.com user account lets you create, edit and comment on Webmonkey articles. You will also be able to contribute to the Wired How-To Wiki and comment on news stories at Wired.com.


It's fast and free.

Webmonkey is a property of Wired Digital.
processing...
Join Webmonkey

Please send me occasional e-mail updates about new features and special offers from Wired/Webmonkey.
Yes No

Please send occasional e-mail offers from Wired/Webmonkey affiliated web sites and publications, and carefully selected companies.
Yes No

I understand and agree that registration on or use of this site constitutes agreement to Webmonkey's User Agreement and Privacy Policy.
Webmonkey is a property of Wired Digital.
processing...

Retrieve Sign In

Please enter your e-mail address or username below. Your username and password will be sent to the e-mail address you provided us.

or
Webmonkey is a property of Wired Digital.
processing...

Welcome to Webmonkey

A private profile page has been created for you.
As a member of Webmonkey, you can now:
  • edit articles
  • add to the code library
  • design and write a tutorial
  • comment on any Webmonkey article
Close
Webmonkey is a property of Wired Digital.

Sign In Information Sent

An e-mail has been sent to the e-mail address registered in this account.
If you cannot find it in your in-box, please check your bulk or junk folders.
Sign In
Webmonkey is a property of Wired Digital.

Install and Use Cygwin

/skill level/
/viewed/
0 Times

Windows provides a little command line utility called cmd.exe, but it has nothing close to the power of the Unix command line and its integrated free tools and applications. Fortunately, especially for addicts of the Unix way, there's a way to use a lot of the Unix tools in a Windows environment. That way is a free piece of software called Cygwin. Cygwin is a Unix-style command line for Windows; it comes with a selection of hundreds of free tools as well.

This page is a wiki. Got extra advice? Log in and add it.


Installing Cygwin

Installation is shockingly easy. Download http://www.cygwin.com/setup.exe onto your Windows computer, and then run the program.

The setup utility walks you through installing Cygwin. When prompted to choose a download source, select "Install from Internet". Choose a reasonably local download mirror from the choices it offers.

Next, it's time to choose which software packages you want included in your Cygwin installation. Choosing All is the easiest option, and it means you won't get that annoying "command not found" error often -- but it takes a long time to download everything, and it takes a lot of drive space. The packages are broken down into categories -- Database, Devel, Editors -- for ease of picking and choosing if you want to grab just the packages you need. I recommend blowing up the window to full screen for this process.

After you've picked some or All and clicked the Next button, all those packages will download from the mirror site and be installed on your machine. You can watch a captivating progress bar while this happens.

Finally you should see the "Installation Complete" message.

If, later on, you realize that now you want a package you opted not to install the first time around, just run setup.exe again and choose it. It'll be added to your Cygwin setup, and any updates will be downloaded too, while your existing installation is left intact.

X and Rxvt

The X Window System is available via xorg. To get it installed, install the X-startup-scripts package from the X11 category. Then, the batch file C:\cygwin\usr\X11R6\bin\startxwin.bat will start Xorg for you, indicated by a black X in the system tray. The X server will sit around waiting for X applications to use your display.

The default Cygwin shell window may be a little cumbersome sometimes, so the rxvt program provides a window that is more compatible with traditional Unix/Linux programs, especially those that might be running remotely. To give yourself a convenient Rxvt icon, make sure that the Rxvt package is installed (categorized under Shells), and create a windows shortcut to C:\Cygwin\bin\Run.exe. Then edit the shortcut's properties so the Target reads: C:\cygwin\bin\run.exe /bin/rxvt -display :0.0 -e bash -login (If you decide not to use X, then leave off the -display :0.0, but some graphical programs may not work.)

Using Cygwin

Launch Cygwin in the way you ordinarily launch programs, be that the Start menu or a shortcut system. It'll bring up a terminal window running the bash shell. Using bash, just a few keystrokes can accomplish things it takes unassisted Windows megabytes of shareware to do.

There's a little bit of rethinking necessary if you're used to Windows' conventions. The C: drive is referred to as /cygdrive/c/ and so forth; your Desktop is at /cygdrive/c/Documents and Settings/User Name/Desktop

To create a whole series of nested directories:

mkdir -p /cygdrive/c/Documents\ and\ Settings/User\ Name/My\ Documents/One/New/Directory/After/Another


(note that you need to put a \ before space characters in directory and file names)

You can rename multiple files, too. Say you have a whole folder called mypics full of JPEGs with names like IMG_0203.JPG, and you'd like to add the prefix "vacation2006" to each file:

for i in mypics/IMG*.JPG; do mv $i vacation2006-$i; done


To remove all empty files and folders from a directory:

find . -empty -maxdepth=1 -print0 | xargs -0 rm -rf 
  • This page was last modified 12:25, 16 July 2008.
Edit this article
Reddit Digg
 
Subscribe now

Special Offer For Webmonkey Users

WIRED magazine:
The first word on how technology is changing our world.

Subscribe for just $10 a year