Mark's Cygwin FAQ


How do I install Cygwin on a networked [internet] computer?

The online installer is pretty much automated.

If you are on an NT Domain (as is the case for all unclassified LM computers, for instance), then you should furthermore see the section on Cygwin and NT Domains.

Improve your classified Cygwin installation by properly configuring bash and rxvt!

How do I install Cygwin on a NON-networked [for instance, classified] computer?

  1. Make an install CD on an unclass box
    1. Use IE to go to, and pick "Install Cygwin Now!"
    2. Save setup.exe to your local hard drive (I put mine in ./My Documents/Received/Apps/Cygwin)
    3. From Windows Explorer, run Setup.exe
      1. On the welcome screen, note the version number in case of problems (these docs were written for Cygwin Setup ver., then click "Next-->"
      2. On the screen titled "Choose a Download Source" (which should have been labeled, "Choose an action"), select "Download from Internet" then click "Next-->"
      3. On the screen titled "Select Local Package Directory", the default should be the same directory holding setup.exe. Accept the default, then click "Next-->"
      4. On the screen titled "Select Your Internet Connection", select "Use IE5 Settings", then click "Next-->"
      5. On the screen titled "Choose A Download Site", pick any mirror you like (I like to hammer, then click "Next-->"
      6. On the screen titled "Select Packages", pick what you like. I typically select something like the following:
        • devel
          • gcc
          • cvs
          • make
        • doc
          • cygwin-doc
        • editors
          • vim
        • graphics
          • opengl
        • interpreters
          • perl
        • Net
          • inetutils
          • openssh
        • Shells
          • rxvt
        • Utils
          • bzip2
          • patch
        • XFree86
          • XFree86-base
        then click "Next-->"
      7. At the dialog "Download complete", click [OK]
      8. Setup should now exit
    4. At this point, three things will be different about your computer:
      • You will now have a directory populated with Cygwin installer stuff (in my case, ./My Documents/Received/Apps/Cygwin), which should be around 50MB.
      • Your registry, should you care to check (don't bother), will have some empty "Cygnus Solutions" nodes. These could be deleted with no effect (but don't bother).
      • You will have a C:\cygwin directory, which will contain nothing but some /etc/setup log files. This is not a working Cygwin installation (you haven't actually installed Cygwin yet, only downloaded the pieces-parts), and could be deleted at this point with no effect (but don't bother).
    5. Burn your Cygwin installer directory (./My Documents/Recieved/Apps/Cygwin, or wherever your setup.exe is) to a CD-ROM.
      • Before burning the CD, you may wish to drag other files on there as well, such as any custom Cygwin files you'd rather not have to manually recreate on the target machine(s), like your .bash_profile, .vimrc, .Xresources, etc.
      • I use Adaptec Easy CD Creator 4 ("data CD"), and simply drag my desired folder into the CD layout window, click "Create and Close CD", and I'm done.
      • Adaptec Easy CD Creator gives me a warning dialog saying that I have a directory titled something like "" needs to be renamed according to Joliette naming standards, or something. I renamed that directory, using the dialog provided, to a simpler "" and had no further problems.
    6. Once the CD-ROM is burned, closed, confirmed, and virus-checked, set it aside. You should be able to use it on your classified machine (later).
  2. Use the CD to install on a classified box
    1. Take the CD-ROM to the classified computer
    2. copy the directory containing setup.exe, and it's contents, to the local [classified] hard drive
      • I used "C:\downloads\cygwin", for no particular reason
      • It may be possible to run the installer from the CD. I wasn't immediately successful with that approach, and didn't bother finding a way to make it work.
    3. run setup.exe
    4. On the welcome screen, click "Next-->"
    5. On the screen titled "Choose a Download Source", select "Install from Local Directory", then click "Next-->"
    6. On the screen titled "Select Root Install Directory", I recommend accepting the default (C:\cygwin), then click "Next-->".
    7. On the screen titled "Select Local Package Directory", the default should be the same directory holding setup.exe. Accept the default, then click "Next-->"
    8. On the screen titled "Select Packages", observe the following procedure:
      1. Next to the top-level category "All", locate a little loopy-loop icon.
      2. Click it once
      3. hold your breath for 15-30 seconds
      4. all categories should change to "Install"
      5. Click "Next-->"
    9. When the installation process is done, click "Finish".
    10. A whole bunch of empty black rectangles will flash across the screen. This is apparently normal. The longer they flash, and the more of them you see, the better a chance that you have a successful installation :-)
    11. Test your local Cygwin install by running C:\cygwin\cygwin.bat (or any of the various links and icons to that file).
  3. improve your classified Cygwin installation by properly configuring bash and rxvt!

Why am I called "Administrator"?

Cygwin has a very messy relationship with NT security. The simple fact is that NT security is very different from Unix security, and a one-to-one mapping just isn't possible. Cygwin does the best it can. You can explore the details if you wish.

First of all, be assured that whatever Cygwin may call you, you are not logged in as administrator, and have no access rights beyond what you had before you installed Cygwin. Still, if you leave yourself logged on with an incorrect username such as "administrator", you'll have all kinds of problems using chmod and other tools. Moreover, even the label of "administrator" is disconcerting to many admins, so it's best to fix it using the process outlined below.

Therefore, if you are on an NT Domain, such as is the case for all LM PC's on the unclassified network, then you must make an extra few steps when installing Cygwin to manually map your login rights.

  1. Install Cygwin as described above
  2. "launch" Cygwin (open a bash or tcsh shell)
  3. add the variable "CYGWIN=ntsec" to your environment, using either:
    bash $ export CYGWIN=ntsec
    csh % setenv CYGWIN ntsec
  4. Type these commands to configure your /etc/passwd:
    mkpasswd -l > /etc/passwd
    mkpasswd -u username -d domain >> /etc/passwd
  5. logout from Cygwin (ctrl-D usually works)
  6. open a new Cygwin shell and make sure you're no longer called "Administrator":
    $ echo $USER
  7. add the above "CYGWIN=ntsec" command to your permanent .bash_profile or .cshrc, if you haven't already done so
In the second call to mkpasswd, above, use the username and domain name you use to log into Windows PC. For me, that's "ziegm" and "ACCT03". For many LM employees, their username will be the same as their badge number. Also, do not reverse the order of the "-u username" and "-d domain" options! Positional sequence matters in that case, unfortunately.

As far as I know, if your PC is not on an NT domain, you do not have to do these steps. In particular, that means that this section does not apply to many classified PC's, which are often not connected to NT domain controllers.

I just installed Octave, and now my Cygwin's hosed!

Yeah, it does that. Just re-run the Cygwin setup.exe program, and manually replace the "C:\Program Files\Octave" path (or whatever) with C:\cygwin (or wherever you put your Cygwin).

Apparently Octave overwrites some Cygwin registry key or other, and makes Cygwin think its "root" is under Octave. Once you fix the Cygwin path, both programs continue to work correctly (AFAIK).

Cygwin Usage

Windows/Cygwin telnet bites. Is there anything better?

Absolutely. I can't stand them myself. All kinds of buggy issues with changing window size, vi sessions getting scrambled formatting, etc.

I use PuTTY, from It's free, it does SSH as well as telnet (if you're into that), it lets you resize windows easily, lets you configure meta-keys for those apps that use's pretty darn good.

About the only terminal apps that I might prefer to Putty are CRT and SecureCRT from VanDyke ($35 and $99, respectively). Still, PuTTY is PlenTY good enough for government work, as it were :-)

I understand that 'bash' is becoming a default on many platforms from Linux to Cygwin, and I have decided that I need to use it more to learn about it. How do I set it up so I can start working productively?

Here is my Cygwin .bash_profile, as a start (Linux users can check ~mzieg/.bash_profile on cvs-oa for an almost-identical Linux example)...
    # .bash_profile

    # set colors and prompt
    export PS1="\[\e]2;peter:\w\007\e[1;36m\]peter [\[\e[1;35m\]\w\[\e[1;36m\]] \u $ \[\e[1;33m\]"

    # configure history editing
    set -o vi
    export HISTSIZE=1000
    export HISTFILE=~/.history
    export HISTFILESIZE=1000
    export EDITOR=vi

    # set aliases for colors
    alias vi=vim
    alias dir='ls -lav --color=auto'

    # winshit
    export CYGWIN="ntsec"

    # display
    # export DISPLAY=localhost:0

    # place nice
    umask 022

    # cvs
    export CVSROOT=""
    export MAKEFLAGS="--no-print-directory"

    # construct path
    unset PATH
    for i in                \
        ~/bin               \
        /bin                \
        /usr/bin            \
        /usr/local/bin      \
        /sbin               \
        /usr/sbin           \
        /usr/X11R6/bin      \
        /cygdrive/c/WINNT/MS/SMS/CORE/BIN           \
        /cygdrive/c/WINNT/system32                  \
        /cygdrive/c/WINNT                           \
        /cygdrive/c/WINNT/System32/Wbem             \
        /cygdrive/c/Program\ Files/Support\ Tools   \
        /cygdrive/c/NTRESKIT                        \
        /cygdrive/c/stuff                           \
        /cygdrive/c                                 \
        /cygdrive/c/S11/DLL                         \
        if [ -d "$i" ] ; then
            if [ -z "$PATH" ] ; then
            echo "Warning: can't append $i to PATH because it doesn't exist."
    export PATH

    # PRISM variables
    export DATA_HOME=~/PRISM/BaseData
    export MAKE_HOME=~/PRISM/BasePrograms
    export PATH="$PATH:$MAKE_HOME/config/bin:$MAKE_HOME/config/cygwin/bin"
And just to complete the magic, here's the corresponding ~/.vimrc to make text editing every bit as enjoyable as command-line navigation :-)
    set autoindent
    set softtabstop=4
    set tabstop=4
    set shiftwidth=4
    set showmatch
    set ignorecase
    set background=dark
    set hlsearch
    set incsearch
    set number
    syntax on
    # only set this last one if you understand the implication re: Makefiles!
    set expandtab

How do I [...] in vi?

  1. vim (Vi IMproved) is available under Linux, Cygwin, SGI, and Solaris, so why not use that instead?
  2. there are some great vim docs here:
How can I make 'csh' my default Cygwin login shell?
Don't bother editing /etc/passwd and changing your "login shell" to /bin/tcsh; it doesn't work :-)

Instead, use the Windows Notepad (or Textpad, or whatever) to create the following file, called "tcsh.bat", in C:\cygwin:

    @echo off
    c:\cygwin\bin\tcsh -l
This will be analogous to the default C:\cygwin\cygwin.bat, which basically does the same thing to launch the bash shell. Why not simply edit cygwin.bat and point it to tcsh instead? You can try that, but it may not be preserved between Cygwin updates/reinstalls/package additions, etc.

Then you'll need working .cshrc and .login files in your home directory. Here are working samples:

    # .cshrc
    # this file gets executed with every subshell

    # is this an interactive shell?
    if ( $?prompt ) then

        # yes, we're in an interactive shell

        # prompt
        set prompt = "%{\033[1;36m%}peter %{\033[1;35m%}[%~] %{\033[1;36m%}%n \%%{\033[1;33m%} "

        # history
        set history         = 1000
        set savehist        = 1000
        set EDITOR          = vim
        set filec fignore = (.o)

        # cmd-line bindings
        bindkey -v          ; # use vi key bindings

        # display
        set DISPLAY         = localhost:0

        # cvs
        # set MAKEFLAGS     = "--no-print-directory"
        set CVSROOT         =
        # aliases
        alias vi            vim
        alias dir           'ls -lav --color=auto'
        alias nslookup      host

    # .login
    # this file gets executed ONCE when the user first logs in

    # construct path
    setenv PATH "~/bin"
    foreach i (             \
        /usr/local/bin      \
        /usr/bin            \
        /bin                \
        /usr/sbin           \
        /sbin               \
        /usr/X11R6/bin      \
        if ( -d "$i" ) then
            if ( -z "$path" ) then
                setenv PATH $i
                setenv PATH ${PATH}:$i
            echo "Warning: can't append $i to PATH because it doesn't exist."

    # terminal options
    stty -istrip            ; # allow 8-bit chars for input

    # share our files with the group
    umask 002
(I'll give a nickle to whomever can explain why that gives a "grep not found" message whenever I login :-)

How do I find out what packages are installed, etc?

Play with 'cygcheck -c' (see 'cygcheck --help' for options)

Cygwin Display

This dinky little 80-col DOS window is crap. How can I improve it?

Yes, you're running bash or tcsh, and thus your commands are being interpreted by a Unix shell, but the window containing the shell remains nothing more than a DOS window. Microsoft never provided much in the way of widgets and controls to those windows, and it can feel a little cramped.

Before you settle on the following tips for improving the DOS window, you may want to replace it altogether using the built-in X Server, complete with xterm, or just run rxvt without the overhead of X. However, any of the three options will work fine for most people. It's all a matter of preference.

To make the DOS window wider:

  1. Open a Cygwin window
  2. Right-click on the title bar
  3. Choose "Properties"
  4. Select the "Layout" tab
  5. Edit the Screen Buffer Size and Window Size with better values (these are what I use):
    • Screen Buffer Width: 100 or 120
    • Screen Buffer Height: 3000 (RAM is cheap)
    • Window Size Width: 100 or 120
    • Window Size Width: 50 (or whatever)
  6. When you click "OK", select "Modify shortcut that started this window". Then your settings will be used for all subsequent Cygwin invocations.
To pick a better font (the default is fuggly):
  1. Follow most of the instructions for resizing the window above, then...
  2. Select the "Font" tab
  3. Pick whatever you want (I like Lucida Console 14pt)

This still isn't as good as a real X terminal! Why can't I just run X?

You can! If you've installed the recommended PRISM developer Cygwin package set, then you can already start a minimal X-Windows GUI just by typing "startx".

However, it's ugly and only barely functional. For a more aestheticly pleasing and practical configuration, I suggest you follow a variant of these steps:

  1. add relevant Cygwin/XFree86 packages:
    • Shells
      • rxvt
    • XFree86
      • fvwm (this looks way better than the default window manager!)
      • Xaw3d
      • XFree86-doc
      • XFree86-man (to help you find your way around)
      • (I don't know how important these are, but I also have libPropList, openbox, and WindowMaker, plus XFree86-fenc, -fnts, -fscl, -fsrv, -lib, -prog, -startup-scripts, and -xserv)
  2. create an .xinitrc file in your Cygwin home directory, like this:
                # merge in defaults and keymaps
                test -f $sysresources   && xrdb -merge $sysresources
                test -f $sysmodmap      && xmodmap $sysmodmap
                test -f $userresources  && xrdb -merge $userresources
                test -f $usermodmap     && xmodmap $usermodmap
                # spawn x
                fvwm2 &
                exec xterm -geometry 120x30
  3. create an .Xresources file in your Cygwin home directory, like this:
                XTerm.VT100.font:           -*-lucidatypewriter-medium-*-*-*-14-*-*-*-*-*-*-*
                XTerm.VT100.boldFont:       -*-lucidatypewriter-bold-*-*-*-14-*-*-*-*-*-*-*
                XTerm.VT100.scrollBar:      True
                XTerm.VT100.visualBell:     True
                XTerm.VT100.loginShell:     True
                XTerm.VT100.background:     Black
                XTerm.VT100.foreground:     White
  4. run "startx"
  5. right-click in the gray desktop background
  6. select "2. Setup Form" from the "Builtin Menu"
  7. put "X"s in every checkbox, then click "F2 - Copy Config File(s)" and finally click "F3 - Restart fvwm"
Now, whenever you type "startx" from a Cygwin window, you'll get a full X-Windows display, more-or-less comparable to what you're accustomed to on "normal" Unix systems like SGI & Solaris.

If you want to adjust the fonts to whatever suits you, type "xfontsel" (from within X Windows) to launch a graphical font selector. After you find a font/size combination that works for you, edit your .Xresources file to configure xterm (or whatever) to use it.

Okay, X is too much. I don't need the overhead. Can I just run an X-like terminal window, but not X itself?

It turns out that this too is possible :-)

If you've installed the rxvt package, you can run it from Windows without having a full X-server running, as long as you don't have a DISPLAY variable set in your environment.

Suggested procedure:

  1. Create an ~/.Xresources file like this:
                ! rxvt.font:          -*-lucidatypewriter-medium-*-*-*-14-*-*-*-*-*-*-*
                ! or...
                rxvt.font:            Lucida Console-14
                rxvt.boldFont:        Lucida Console-14
                rxvt.scrollBar:       True
                rxvt.visualBell:      True
                rxvt.loginShell:      True
                rxvt.background:      Black
                rxvt.foreground:      White
                rxvt.saveLines:       3000
                rxvt.cursorColor:     Green
                rxvt.scrollBar_right: True
  2. create a shell script like this one, so that you can pop up a new window whenever you want from within an existing shell:
                # ~/bin/win
                unset DISPLAY
                rxvt -e bash -login &
  3. create a DOS batch file like this one, so you can likewise create a new window by clicking an icon from Windows:
                @echo off
                REM place in C:\cygwin\rxvt.bat and put
                REM a shortcut on the desktop :-)
                c:\cygwin\bin\rxvt -e /bin/bash -login

Other Sources of Information