Tuesday, April 10, 2007

Windows with the Power of Linux

No matter how hard we try to avoid it there will always be a time were be are forced to work with Windows PC's. There will always be a friend/family that needs some help with their Windows machine or the school/work project that uses only Windows development tools (i.e. Visual C++).

Forced to work with Windows OS's for several years I have learned configure Windows in a way that makes it more enjoyable to use (i.e. make Windows more like Linux) and here I present my configuration to all unfortunate Linux/Unix users forced to use Windows at work or school.

The main problem I have with Windows is that by default it does not offer too much functionality and flexibility. Even after adding some additional software packages to Windows I am 400% more productive in a Linux console using the set of GNU utilities than using for example MS Excel.

Just as an example in Linux it is easy to find the number lines that contain a certain pattern in a CSV file with a single line command (i.e. cat file.cvs | grep patt | wc -l). I really don't know how to do it in Excel or how to compare two excel sheets and extract the differences to a third sheet (i.e. diff or comp in Linux). Granted that I am not an expert using Excel but this is just a simple example. I can handle far more complex files with console commands and small scripts that would be far more complicated to do with any GUI alternative.

To alleviate Windows lack of functionality and flexibility I simply install as much Linux tools as I can on my Windows installation to give it that Linux feeling. This gives me the power and flexibility of Linux combined with the Windows development tools I need to fulfill my daily tasks.

Cygwin? Thanks but no thanks

When talking about Linux tools on Windows we all know about Cygwin. Cygwin is good if you want to alienate Windows completely and pretend you are running a full installation of Linux. The Windows OS passes from being a complete OS to be only a hardware and X11 interface for Cgwin.

You have your home directory inside the Cygwin environment (different from Windows home) and you can install all sorts of tools, applications and even complete servers inside the Cygwin environment. Since everything is hosted inside the Cygwin environment it is difficult to integrate Windows applications with Cygwin and Cygwin applications with Windows.

For example trying to set up a C++/C# development environment in Cygwin using Visual C command line development tools can be a challenging task. I also had a lot of trouble to get the Windows DDK (Driver Development Kit) environment to work inside Cygwin.

All I needed was the ability to use Linux commands/applications like ls, cat, wc, grep, find, vim to handle my programs source code and use Windows build tools like nmake and cl to compile them.

GNU Core Utils

This is the set of GNU utility commands I so much love and they are all contained in a single package UnxUtils.zip.

To enable these utilities on the Windows Command shell I simply extract the contents of the "/usr/local/wbin" directory (without the paths) inside a directory listed on my PATH (i.e. C:\Apps\UnxUtils). Once the utilities are in my PATH I can start using them to manage source code files as I do in Linux.

There is also another port of these utilities that is more actualized (GnuWin32 project) but I have been using the UnxUtils package for years without problems so I haven't tried the new ones.

If you are using Windows Vista you may better try the new GnuWin32 utilities as the home page claims Vista compatibility. I am not sure if the UnxUtils supports Vista.


The UnxUtils package contains a version of Wget but it is a little outdated. I prefer the Heiko Herold's version that supports SSL and can be found here.

Simply open the Zip file and extract the wget.exe, the two .dll files and cacert.pem inside the UnxUtils directory (i.e. C:\Apps\UnxUtils) overwriting the existing files. This way we replace the wget that comes with UnxUtils with this new one.


No serious development should be done without a CVS or SVN repository. To install Subversion in Windows simply download and run the installer.



I have been a Ruby fan for a long time, even before Rails made it popular. I use it for almost everything from complete GUI applications to small scripts to process text files. Installing Ruby in Windows is easy using the one-click installer: http://rubyforge.org/frs/?group_id=167&release_id=10461

With this installer you get much more than just Ruby. You also get RubyGems and a lot of libraries and extensions for developing rich Ruby applications. You can even use RubyGems to install Rails and Mongrel to develop web applications.


I am a vim user and without it I am almost useless as a programmer. Well not that useless but after years of trying other editors I always come back to vim. In Windows I use the gVim self installing file from here.

During installation make sure you install the .bat files for command line use. Without these .bat files you won't be able to call vim from the command prompt.


The powerful opennssh to transfer files securely from one machine to another. This is also a Windows installable that you can get here.

This installable file includes some Cygwin command utilities like ls.exe, mkdir.exe and rm.exe that are needed for the oppenssh-server. If you install the server these commands will be in your PATH and may conflict with those of the UnxUtils package.

To solve this you can install only the client or if you need the server make sure the order of directories in your PATH variable have the UnxUtils directory listed before the openssh bin directory.

X Forwarding with OpenSSH

The Windows version of OpenSSH above supports X-Forwarding that allows me to use my GUI applications at my home computer (Kontact, Kiten, Kopete, etc.) remotely from the Windows PC I use at work/school.

I blogged about this in a previous post so look there if you are interested. I will only mention that if you use XMing as X11 server remember to set the DISPLAY environment variable to reflect that used by XMing (i.e. SET DISPLAY=

Tab-completion in Windows 2000

This is an old known trick but for completeness I mention it here. In Linux and Window XP we have a very useful feature called tab-completion. With it we can start typing any command, file name or path name and press Tab to get the rest automatically. This is very useful specially in Windows that the paths are long and contain spaces (i.e. c:\Program Files\Documents and Settings).

In Windows 2000 this feature exists but is not enabled by default. To get "tab completion" in Windows 2000:

1. Hit the "Start" button
2. Select "Run"
3. enter "regedit", hit OK
4. Expand "My computer" (by clicking the little [+] beside it)
6. Expand SOFTWARE
7. Expand Microsoft
8. Expand Command Processor
9. Double-click "CompletionChar"
10. Replace the value that's there with 9 (ASCII equivalent of the TAB key)
11. Click OK

Now open a command prompt, start a command or directory path name and then start pressing Tab to scroll on the possible auto completion options.

These instructions were copied from Anders blog post .

Setting The Environment

In my Windows machines I usually create a batch script (C:\LINUXENV.BAT) where I configure some environment variables like PATH to include the newly installed UnixUtils. I also add some other variables for development (http://www2.blogger.com/img/gl.link.gifnot shown here) and some command shortcuts.

SET PATH=C:\Apps\UnxUtils;%PATH%
doskey alias=doskey $*
doskey clear=cls
doskey vi=vim $*

There are two ways to use this script. First we can open a command prompt as normal in Windows (i.e. Start->Run->CMD.exe) and call the C:\LINUXENV.BAT from within it or we can create a shortcut that we can just click (see next section).

Creating A Shortcut

Instead of running the CMD.exe shell and then calling the C:\LINUXENV.BAT batch script to set up our environment we can simply create a shortcut on our Desktop that when clicked will open a command shell (CMD.exe) load the LINUXENV.BAT and leave the prompt waiting for use to input commands to it.

In the Desktop context menu (i.e. Right Click) choose create new shortcut. When asked for the command to run put:

%comspec% /k C:\LINUXENV.BAT

And in the name put anything you like (i.e. Linux CMD). Now when you click in that shortcut you will get a Windows command prompt but with the Linux power and flexibility.

Windows OSS Applications

These days there are many OSS applications that run natively in Windows that can make Windows even more functional and flexible. The best part is that most of these applications can run equally on Windows and on Linux making the transition from on OS to the other less complicated.

For a comprehensive list of Windows OSS applications check this link: http://shsc.info/usefulwindowssoftware.

My personal favorites are:

1 - Firefox loaded with web development plugins
2 - Thunderbird
3 - ClamAV or AVG
4 - Spybot Search & Destroy
5 - Amaya for some casual HTML/CSS editing of my blog.
6 - Scite Editor (if Vim is not available)
7 - XMing to enable SSH X-Forwarding

No comments:

Post a Comment