Tille - I can see you, read those man pages!   Tille's Site

Changing the face of Windows

Having an MS Windows desktop forced upon you is dreadful. You can only take it so long before you want to throw it out of the window. While at times the Windows desktop is a necessary evil, or at least an inevitable one, there are ways to ease your suffering.

Cygwin offers the tools to hide the embarrassing fact that you are using the "wrong" sort of system and can help a great deal in refurbishing your workstation.

This article glues together the odds and ends that you need to know about to make your life more comfortable.

Cygwin provides substantial Linux functionality on all non-beta, non "Release Candidate" x86 32 bit versions of Windows, starting with Windows95, with the exception of Windows CE. It is a DLL that acts as a Linux API emulation layer. Included with the Cygwin suite are most of the common Linux command line tools and quite some graphical applications, so that you can have the look and feel of a Linux machine on top of your MS Windows box.

What Cygwin is not

Cygwin does not convert your Windows machine into a UNIX-compatible one. It does not make it understand UNIX signals, PTYs and such, it only provides mapping of UNIX actions onto the Windows platform. I is not a way to make native Linux applications run on Windows. If you want an application to run on your Windows workstation, and it is not yet in the Cygwin suite, then you will have to compile the source. Another solution is to run the application, if it is a graphical one, remote using X functionality, we will discuss the setup for remote display in this article.

Installation:

You can freely download the Cygwin tools from the Cygwin website. Click on the "Install Cygwin now" icon and save the setup.exe tool somewhere on your disk.

Then double click to install the Cygwin base configuration. You can either directly install everything, or first download in a directory on your local system and then install from that directory.

When the installation procedure asks to specify the Root Install Directory, it is best to change the default C:\cygwin to some other path in order to keep Cygwin files separated from your native Windows files. There have been problems with this in the past, and even though Cygwin developers are 99% sure that no conflicts can happen any more, it is wise not to take risks. I installed Cygwin in D:\cygwin.

You can install the Cygwin programs just for your own usage or system wide. If you are not too deeply involved with development on Windows, select the UNIX text file type. If you need text files from your Windows machine, in some cases it is necessary to use DOS file types. In any case, the CYGWIN variable can be set to explicitly specify the text file type that you want to work with. Compatibility with DOS text files is built in. Details about this and other UNIX to Windows mapping specifics can be found in the user guides on the Cygwin website.

Next, specify the package directory that will be used for downloading. With Firefox installed on my machine, this was C:\Program Files\Mozilla Firefoxw by default. For connecting to the Internet I have to pass an ISA proxy/firewall server (runs on Windows), which does not agree with the normal standards. So I had setup.exe import the MS IE5 settings in order to download through the proxy server. This worked, at least partially, I will explain more about the ISA proxy/firewall troubles later.

Usage of a mirror is required. If you try to download directly from the Cygwin site you will get errors, so select a mirror near you. A minimal installation requires the base packages, which include the DLL, a Bash shell, the coreutils, findutils, diffutils, documentation, libraries and a couple of basic UNIX tools like tar and grep. Select these basic packages and let the setup.exe tool do the rest.

The X Server

The X server, which is most important to me because I want to be able to do remote display, is not included in the base package. I could install most packages using the setup.exe tool, however the company proxy/firewall settings prevented me from downloading the bigger packages, such as the 75 dpi fonts, using this method. I tried playing with the proxy settings in the setup tool for a while, but to no effect. In the end I manually downloaded the necessary packages from the mirror into a local directory, using HTTP in my browser, and instructed setup.exe to use that local repository. After installing all the packages necessary for running X, you can start the server from the bash shell using several methods:

  • an MS-DOS batch file
  • a shell script
  • using startx
  • calling XWin.exe directly

Example batch files and scripts are included in the Cygwin package. When the X server is started successfully, the X logo is displayed in the task bar of your Windows desktop.

From this moment on, your Windows workstation can display UNIX graphical applications. For testing, log in to a UNIX or Linux host and use a simple and small program like xclock or xlogo. When everything proves to work as it should, you can start the applications you need.

Remote display

Use the X11 forwarding feature of SSH to get rid of the export DISPLAY routine that is inherent to XDMCP. When I was trying to install SSH, the proxy server was making a mess of it again, so I did it manually and got errors because a cryptographic library which is in the SSL package was not installed yet.

When installing SSH, don't forget to add SSL. If you use the setup.exe tool, dependencies are satisfied automatically.

There is no default SSH configuration present. You will need to go through these steps to set up SSH decently:

  • Copy sshd_config and ssh_config from an existing UNIX machine into the Cygwin /etc directory, make sure X11 forwarding is enabled.
  • Generate SSH hostkeys. This does not work because the file does not exist. Solution: touch /etc/ssh_host_dsa_key, then generate the key using ssh-keygen and overwrite.
  • Change permissions on your private host key to 600.
  • Run mkpasswd and mkgroup, which will create UNIX-style /etc/passwd and /etc/group files based on MS Windows user information.
  • Create the SSH privilege separation user, adding a line like the following to /etc/passwd:
    sshd:*:74:74:SSH Privilege Separation User:/var/empty/sshd:/sbin/nologin
  • Start /usr/sbin/sshd

For enabling remote display, first set the DISPLAY variable locally in a Cygwin Bash window:

export DISPLAY=localhost:0.0

Then start ssh with the -Y option:

ssh -Y user@remote_host

Check the DISPLAY variable when you are logged in to the remote server, it should say something like remote_host:14.0. You can now start any graphical UNIX application, it will be displayed on your Windows desktop.

For the real die-hards

While testing the graphical applications, I noticed that quite a lot of Gnome applications are included in the package list. All the libraries that you need to run Gnome programs are already ported, however a full-blown desktop is not yet available - unless you do some compilation yourself, of course. As a workaround, use the standard -query option to the X server to display a complete remote desktop:

/usr/X11R6/bin/XWin.exe -query remote_host

On Solaris, the XDMCP feature (X Display Manager Control Protocol) is still enabled by default. On Linux, you will need to change your XDM configuration, preferably serve fonts and change your Gnome or KDE configuration. On my Fedora box, I did the following:

  • Comment the line "DisplayManager.requestPort" in /etc/X11/xdm/xdm-config.
  • Uncomment "#* # any host can get a login window" line in /etc/xdm/Xaccess.
  • Comment "no-listen = tcp" in /etc/X11/fs/config
  • /etc/init.d/xfs restart
  • In /etc/X11/gdm/gdm.conf, change "Enable=false" to "Enable=true"
  • pkill -HUP gdm

Then from the Windows station, make sure that the X server is stopped before entering the X -query command.

NOTE: This is for exercising only. There are better alternatives for remote display of entire desktops, for instance VNC.

More information can be found here:

  • http://www.cygwin.com: user guides, history and background
  • http://x.cygwin.com: Cygwin/X documentation
  • http://www.tldp.org/HOWTO/XDMCP-HOWTO: XFS, XDM and GDM configuration
Home
© 1995-2010 Machtelt Garrels - tille - Powered by vIm - Best viewed with your eyes - Validated by W3C - Last update 20100511