Installing and properly configuring Cygwin

by alex

Cygwin is a Linux-like interface for Microsoft Windows. It’s very neat. In my case I have a Lenovo X230 tablet and it’s just less of a nuisance and more functional to use MS Windows. Also, even though Wine works very well, it’s still not perfect. That way I have Windows installed and simply use Cygwin to easily access to my Linux server and have that Linux feel in Windows.

Cygwin is very easy to install and can be downloaded from here. There is a 64-bit version, but at the moment it is lacking some useful packages like rxvt. During install you will be prompted to choose a mirror (most work well) and which packages to install. Be sure to install wget, because we will need it for customizing cygwin later.

Now, if you need to install some packages on Cygwin, the usual procedure is to re-run the setup executable. This is not very convenient. Fortunately there’s a better way. Stephen Jungels has written a command line installer for Cygwin which works just like apt-get. You should visit apt-cyg webpage here and install it.

Now, in Cygwin to access VI Improved, which comes selected for install by default, you should type vi and not vim (as you may be used to) .

The problem is that if you try to run vim, it enters in compatibility mode, and some stuff simply won’t work. You may notice that you cannot see in the bottom in which mode you are, backspace won’t probably work, etc… This is because it is lacking a .virc file in your home folder.
Simply creating an empty .virc file using touch .virc in your home folder should be enough.

Now, something I strongly recommend, is to install rxvt. It is, in my opinion, a better shell than the standard Cygwin one.
If you have installed apt-cyg, simply issuing apt-cyg rxvt should be enough to install it (mind you, that the 64-bits version of Cygwin is, at the moment I am writing this post, lacking rxvt!)

You may notice that once you start rxvt the background, foreground, and font are quite different from the usual shell. To configure this, as well as the appearance of the window, you need to create in your home directory a file named .Xdefaults.
Then add the following to this file:

Rxvt*geometry: 100x30        ! WxH
Rxvt*background: #000000
Rxvt*foreground: #ffffbf
Rxvt*scrollBar: True
Rxvt*scrollBar_right: True
Rxvt*font: Lucida Console-12
Rxvt*SaveLines: 2000
Rxvt*loginShell: True
! VIM-like colors
Rxvt*color0:    #000000      ! pure black
Rxvt*color1:    #FFFFFF      ! pure white
Rxvt*color2:    #00A800      
Rxvt*color3:    #FFFF00
Rxvt*color4:    #6495ED      ! cornflower blue
Rxvt*color5:    #A800A8
Rxvt*color6:    #00A8A8
Rxvt*color7:    #D8D8D8
Rxvt*color8:    #000000
Rxvt*color9:    #FFFFFF      ! pure white
Rxvt*color10:   #00A800
Rxvt*color11:   #FFFF00
Rxvt*color12:   #6495ED      ! cornflower blue
Rxvt*color13:   #A800A8
Rxvt*color14:   #00A8A8
Rxvt*color15:   #D8D8D8

We are still not done. You it may happen that if you SSH into a Linux machine and try to use some programs such as less, man or top they will fail with errors such as “unknown terminal type”. The problem is the TERM variable which rxvt sets to rxvt-cygwin which is unrecognized by your remote machine.
Simply add

case "$TERM" in

to the .bashrc file in the home folder of your remote machine and things should work flawlessly.
An alternative, in case you are using a shortcut to run rxvt, is to add the flag -tn xterm.

If you are planing on using X, you should install the package xinit in Cygwin.
You can then run the Xserver and open an X terminal by running:




For more information on this, you should consult the Cygwin/X page.

Note: If you don’t see any X window and find yourself unable to start the X server, it may already be running. You may need to kill the process


using the task manager.

There are many other things that you can customize in Cygwin, but this should be enough to get you going.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.