October 5, 2008

Bringing Linux to the Windows Desktip with “Cygwin”

Tech tips - 185

By Scott Nesbitt – Sunday, September 14, 2008

PullQuote 185Like it or hate it, there's no denying that the command line is a powerful, flexible tool. The number of useful utilities available more than balances out the command line's reputation for not being easy to use.

That said, the default Windows command line is lacking – especially when compared to its UNIX or Linux counterparts. It doesn't have to be that way, though. You can bring the full power of the Linux command line to Windows with an application called Cygwin.

Cygwin_installOverview of Cygwin

Cygwin is an environment and a set of application that emulates the Linux command line within Windows. Originally called gnuwin32, Cygwin was developed by a company called Cygnus Solutions (now part of Linux vendor Red Hat) in 1995. The aim of Cygwin was to bring the software development toolchain used by UNIX and Linux hackers to 32-bit Windows (Windows 95 and NT at the time). With Cygwin, developers could write cross-platform software without many changes to the underlying code.

Cygwin grew from a set of programming tools to a complete implementation of the popular Bourne Shell command line environment. There's also a version of Cygwin called Cygwin/X, which is a version of the X Window System that runs on Microsoft Windows. Note: Cygwin/X may be covered in a future TechTip.

 

Who uses Cygwin?

Obviously, Cygwin isn't a tool that will appear on everyone's Windows desktop. It's a quite specialized, almost techie tool. Cygwin has its roots in cross-platform software development, so obviously one of the major groups of users is programmers; especially programmers who are writing software for multiple, UNIX-like platforms. With Cygwin, they can do their work and not have to worry about needing a second desktop computer running another operating system. Anyone doing system administration will find Cygwin's array of network utilities, and other command line tools, useful. Using them, an administrator can quickly gain access to and efficiently work with a server.

Cygwin is also useful for anyone who wants to learn about Linux or UNIX. That could be a curious Windows user who plans to make a switch, someone who needs to learn either operating system as part of their job, or who wants to take advantage of the wide range of Linux utilities that Cygwin offers. I'm in the latter group. Whenever I use my laptop computer running Windows, I use Cygwin to:

  • Securely log into my Web sites using ssh
  • Convert documents written in Markdown to HTML
  • Work with many of the same scripts and utilities that I work with on my Linux laptop

And quite a bit more.

 

Getting started

Obviously, you need to download some software in order to start working with Cygwin. There is one file that you need to get: setup.exe, which is the setup program. Once that file is on your hard drive, double click it to start the installation. The setup program is a wizard that guides you through the installation and (when it comes time) update process. Unless you have a reason to do otherwise, install from an online source. The wizard enables you to choose a site from which to download the application packages. When choosing a location, find one that's relatively close to you and select a site that uses HTTP instead of FTP – I've found HTTP to be faster. Your results may vary. If you're planning on installing Cygwin on multiple computers, then you might want to choose the local installation option. This will enable you to put all of the packages (another name for Cygwin applications and libraries) on a shared drive so others can access cygwin_terminalthem as needed. Going with the default installation will only install the basic Cygwin system and a few utilities. That basic installation is functional, but doesn't do much. You need to specify what you want to install. That's where the fun begins. There are over 1,100 packages available. You definitely won't need them all – and installing them all at once will take a long time. So, what should you choose? It depends on what you're doing. If you're a developer, you'll want to install various compilers, interpreters, and libraries. A system administrator will want to install tools like ssh, ftp, less, vi, and the like. Consult the package list at the Cygwin Web site for more information that will help you make your choice.

Installation will take anywhere from a couple of minutes to much longer, depending on what you've decided to install. Once the process is complete, you can find Cygwin in the folder c:\cygwin.

Note: For more information about the installation options, read this document.

Using Cygwin

Assuming that you're successfully installed Cygwin, there are three ways in which you can launch it: from a desktop icon, from the Start menu, or from within Windows Explorer. For the latter, you'll have to install a package called Cygwin Prompt Here (sometimes called chere). It's a small application that adds an item to the context menu in Windows Explorer. Just right click on a folder, and then choose Bash Prompt Here. A terminal window opens in that folder. There's no need to use a lot of keystrokes to get there!

 

The file system

Regardless of what method you use to start Cygwin, you'll find the file system to be … well, a bit interesting, especially proscar and propecia if you're not cygwin_logofamiliar with Linux or UNIX. Whereas the Windows command line uses backslashes to separate directories (C:\Windows\System32), Cygwin sticks to its UNIX roots by using forward slashes. Everything starts from the root directory (/), and Cygwin uses standard Linux directories – like bin, etc, lib, and the like.

You can navigate to the Windows file system by specifying /cygdrive/c. From there, you can use the cd command to change to whatever directory you want to.

 

Using Cygwin's programs

To use any of Cygwin's programs, just type the name of the program in a terminal window and press Enter. For example, to get a directory listing just type ls. Of course, depending on the program, you might have to specify some options and/or a file name. You can read this TechTip and this one to learn a few basic Linux commands. Or, you can read the Cygwin user manual.

 

Conclusion

Cygwin is definitely not for every computer user. It's really a tool for the techie or the technically curious user. But if you need to use the Linux command line and don't want to invest in a second computer, to partition your hard drive, or use virtualization, then Cygwin is definitely a good choice. Best of all, it's free!

Permalink • Print • Comment

Leave a comment

You must be logged in to post a comment.

Made with WordPress and Semiologic • Sky Gold skin by Denis de Bernardy