Use Linux Commands and Shell Scripts directly in Windows

Did you know that there is a way to run Linux commands and shell scripts directly in Windows? No Linux partition required. No dual boot required. All you need is CygWin, which is available for free at http://cygwin.com.

You can think of CygWin as a Linux emulator that runs within Windows. Technically, it is not an emulator, because it cannot run just any Linux program directly. Programs have to be specifically ported to CygWin first. The good news is that hundreds of such programs are available at your fingertips via the CygWin installer, and yet more are available on the side. So, for all intents and purposes, it really is a Linux emulator.

The best of both worlds: CygWin, therefore, is a great way to learn Linux when no Linux box is available. More importantly, CygWin brings you the best of both worlds, allowing sophisticated, powerful, atomic Linux commands to operate in the Windows world. The number of uses for CygWin are incalculable. This article will briefly explain why CygWin is a good thing and, hopefully, whet your appetite for more. This is only the first of what promises to be a long string of articles that will appear on CodeJacked to tout and exemplify the many uses for CygWin.

Shell Scripts: CygWin allows you to use shell scripts to automate tasks that simply cannot be done with a Windows batch file.

  • First of all, many people find that it is easier to automate sophisticated processes using shell scripts than to do so by writing batch files. The control structure for Windows batch files evolved over time in a very haphazard manner, whereas shell scripts have always enjoyed a programming-language-like structure.
  • Secondly, there’s a huge list of Linux commands that have been converted to run under CygWin. In many cases the Linux command is unique, with no Windows counterpart to speak of. In other cases, there may be a Windows counterpart, but the Linux version is more powerful, or it provides an alternate way to specify the options, or a combination of the two.
  • Even in cases where the process to be automated could easily be done with a batch file, using a shell script instead means that it will not have to be converted later should the process be moved to a Linux box.
  • Another big advantage to CygWin is that, since it is free, open-source software, there’s nothing to stop you from running the latest and greatest releases in order to take advantage of its full potential. Compare this to the feature set of Windows batch files which depend on the version of Windows that you are running.

Individual Commands: Here are just a few of some popular commands that run under CygWin:

  • rsync - Synchronizes two file folders (remotely) so that the files in the target folder are up-to-date with corresponding files in the source folder (fast).
  • conv - Converts the line endings of text files to/from DOS style and UNIX style.
  • tidy, catdoc, etc. - Utilities for manipulating text files.
  • openssh - Generates a private/public key pair for use with SSH security

Graphical Environments: CygWin even supports three different graphical environments out-of-the-box, including KDE and Gnome.

For those of you who cannot wait to get started, the CygWin user guide (http://cygwin.com/cygwin-ug-net/) is good, but terse. It even includes two different getting-started guides: one for people who are more familiar with Windows than UNIX, and one for the other way around.

Coming up next: Six Important Tips for Installing CygWin

Trackbacks & Pings

Comments

  1. i would like to know more of these things.

  2. I have downloaded & tried but it is not able to execute all linux commands..

    specially basic commands like time, ls, cal

    so is there any better solution to run linux command on windows 7??

Post a Comment


Your email is never published nor shared. Required fields are marked *



© 2006-2007 Maxim Software Corp.  All rights reserved.