Some notes on setting up Cygwin
Updated December 2006
If you find this page, you should know that I am far from being a unix
expert! The programmers I work with would find it highly amusing
offered advice on anything having to do with setting up a
computer. This page is more for me to keep track of what I've
done rather than to offer a brilliant template for others, but you're
welcome to see
what I've done. I also strongly suggest looking at this
page, which is written by someone who knows
what he or she is doing instead of someone who is bumbling along.
But even bumblers can get Cygwin going pretty quickly -- the program's
authors have made everything pretty painless.
- Get the "setup.exe" tool from www.cygwin.com.
- SETUP leads you through the
downloading and installation procedure. Put it in a convenient
folder -- InstCyg or so is useful, since it's then easy to cd to
the Cygwin root directory, titled cygwin, using the first
letter or two and hitting the tab key to complete the string. This
is also where the downloaded files wind up that will be unzipped into
the installation. This directory is small enough that you can
back it up on a CD for reinstallation or repair if need be; SETUP will
let you insall from a local repository..
will lead you through a series of choices (keep the default choices in
general for directory names and to install from the internet, but
you'll need to pick a local mirror site for the files), and will
let you choose the packages you want to
install with a nice GUI.
- You can also download the entire distribution and then install
from the local files if you want -- this might be useful if you want to
add packages later but don't want to change version. It's not too
useful if you want to stay more or less updated.
What I installed
- I wanted TeX and program development environments, and like to
in X-windows. From the
GUI that runs from the setup.exe program (it takes a while for setup to
the archive the first time) I selected the following files beyond the
defaults in addition
the files set by the default settings in each category (setup is smart:
something will select most but sometimes not all other necessary files,
but the setup program checks for links at the end)
- (bison, byak, and flex)
- (gawk; sed is in the Base default)
- tetex (then don't forget to run texconfig
to select paper size and other default options)
- tetex-extras (for BibTeX stuff in my case; run texconfig rehash so TeX knows
where to find the extra files)
- X11 (no subdirectories, select install for the whole package;
the default option isn't quite enough for what I'm doing)
- Cygwin's package search page, www.cygwin.com/packages/,
very useful finding missing files or commands. The setup program
is smart and automatically gets most of the dependent files, but when
you're looking for something you want or are missing...
- Do a search to identify Windows programs that use cygwin1.dll and have their own
versions of this dll (e.g. ds9, fv,
etc.). Rename their versions as something simple (I used
cygwin1X.dll) and modify the Windows path to include c:\cygwin\bin,
whatever bin directory is off the cygwin root directory.
This prevents multiple versions of the cygwin1.dll from running at the
same time. To get to the Windows path, right click "My Computer"
icon, "Properties" option, choose "Advanced" tab, then "Environment
button to get to the User variables. Then either define a new
or edit it to include c:\cygwin\bin (directories within
variable are separated by semi-colons)..
- Add or set the
Windows environment variable HOME
-- this is
where you wind up when you type cd at
a Cygwin prompt.
- The Cygwin initial
paths and other setup parameters are in c:\cygwin\etc\profile.
After a little editing, my Cygwin path is something like: PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:.:$PATH"
In previous versions /usr/X11R6/bin had
to be first in the list to pick up the version of ghostscript (gs) that
X-Windows, but this seems to have changed in recent releases. The
problem before was that a version that didn't have an x11 device was
ahead of the X version in the default path. I
also added the reference to the current directory at the end of the
Cygwin native path but before the Windows path. A full copy of my profile
file is below and can be used as a model.
Starting the X-Windows manager
- To get a single -- one and only one -- X-Window terminal, type startx.
If there is no c:\.xinit
file, the manager will use c:\cygwin\etc\X11\xinit\xinitrc. I copied
to c:\.xinitrc so I could change
without breaking the distribution's version. I changed the colors
have it start in a c-shell by modifying the line toward the end that
the window. This mode is useful if you want
run something (e.g. ssh -X) that launches its own X-windows.
- It is also possible to launch multiple windows here, but I prefer
to switch to a full X-window environment when I am running a bunch of
applications under Cygwin -- e.g. working on a LaTeX file.
- A number of managers are available for running multiple xwindow
terminals. A nice one is Window Maker. To run it (assuming
it's installed), type in the
DISPLAY=localhost:0.0 (I added this to my
version of c:\cygwin\etc\profile
- xwin &
- wmaker &
- Even easier, put this modified version of \usr\X11R6\bin\startxwin.sh,
in the \usr\X11R6\bin
directory or somewhere else in your path, and then type
(the display must still be set properly
and the script must be executable, of course). In addition to
changing the script to bring up Window Maker with the clipboard enabled
between Cygwin and Windows, I added some of the preamble from the startx
script which seems to solve some compatibility problems that xdvi has
with ghostscript. With this change xdvi shows
embedded postscript figures and not just the bounding box outline.
- To use an xterm through ssh, use the -X option: ssh -X user@host
Setups for ssh and scp
ssh and scp work fine but benefit by the manual creation of a
to put the .ssh information to
track of known hosts. They work fine without, but ask each time
if you trust the host, so creating the directory simplifies things.
As mentioned above, the explicit -X option
is necessary if you want a remote session to pop up X-windows in an ssh
session: ssh -X
user@host. -Y may work here if -X causes
It's also necessary
to type xhost + at the local prompt
to let the remote system write to the local screen. This + lets
the whole world write to your screen if they want, so if you are
worried that someone may send things to your screen you can be more
specific; see the man pages.
For an XP installation, here are my personalized
(modified version of c:\cygwin\etc\profile, written over
original version, now saved as profile.org)
(modified version of c:\cygwin\etc\X11\xinit\xinitrc
(modified version of c:\cygwin\etc\csh.cshrc saved as
- .login (modified
version of c:\cygwin\etc\csh.login saved as
(an emacs initialization file that works for me -- there are
many other examples and discussions on the web)
(modified version of c:\cygwin\usr\X11R6\bin\startxwin.sh
saved as c:\cygwin\usr\X11R6\startxwin)
emacs for both XP and Cygwin
I like the gnu
emacs port for windows a lot and keep that as my default text
editor in Windows. To get the aspell spelling program running
on XP and Cygwin:
- In c:.emacs,
add the line (setq-default
ispell-program-name"aspell") -- then emacs knows to
use aspell instead of ispell
- In XP environment variables, make sure that
c:\cygwin\bin\ -- now
XP knows where to find aspell.exe
- Dictionary is c:.aspell.en.pws
-- opened and appended my old .ispell-english
to this file
Setting up LaTeX with other packages
A very useful set of references for installing packages under LaTeX are
the pages connected with AASTeX, especially the installation part of
This also explains some of the other uses of texconfig.
Notes on rsync
To rsync to another disk, for instance disk e: (easy to see which are
available with the df
--delete sourcedir/ /cygwin/e/destdir/
removes files that have been removed from the source directory but will
not overwrite newer files in the destination,
To rsync to another system with ssh over
rsync -avu --delete -e ssh sourcedir/ username@machine:~/destdir/
To avoid typing passwords for each network transfer:
- Generate key for ssh with ssh-keygen.
Take all defaults including a blank passphrase (otherwise you'll want a
passphrase and to invoke an ssh agent, a good idea if you have any
security concerns past the most basic ones). Keep track of the
- Copy the generated file, id_rsa.pub,
to the ~/.ssh
directory on the remote machine. Rename it or append it to a file
The file must
be read-write for the owner only (chmod 600).
- It is possible to
edit this file to restrict access to this mode following instructions
in this link.
- The counterpart to
the public file is id_rsa; that may be copied
(securely!) to other local machines so you can log in from them as well.
Questions or comments? Please contact Andrew Harris.