Getting Started With Cygwin

Cygwin is a collection of tools which provide a Linux look and feel for Windows. It includes the equivalent of many Linux binaries, such as cat, nano, less, etc. It also includes a nice command prompt, far nicer than the built in Windows command prompt. I use Cygwin almost exclusively on Windows, since the available Window command prompts are so awful. You can run available Linux programs as well as any Windows programs from the Cygwin shell. I use Cygwin for working with Git, Vagrant and SSH mostly.

cygwin

 

Installing Cygwin

  1. The first step is installing Cygwin. To do this, you must download the installer. I recommend the 64 bit installer, assuming you’re on a 64 bit OS.
  2. When you run the installer, make sure to select “Install from Internet” on the “Choose A Download Source” page
  3. It doesn’t really matter where you install it, but I recommend the default path (or at least installing it to the root level of one of your hard drives).
  4. Picking a download site isn’t super important, I use a random one. The university ones (.edu) seem to work the best. I’d also recommend using http:// ones, as I’ve had firewall issues when using FTP before
  5. The select packages screen is very important. This is where you pick what Linux utilities will be installed and available via Cygwin. The ones I recommend are:
    • All > Editors > nano (Light weight editor)
    • All > Editors > VIM (Heavy weight, popular editor)
    • All > Net > openssh (SSH client)
    • All > Utils > ncurses (Screen utilities, gives you access to the clear command)
    • All > Web > wget (Download files from the web)
    • All > Devel > git (Distributed version control system)
  6. Proceed with your installation

Configuring Cygwin

Cygwin has some annoying default behavior that I would strongly recommend changing.

  • Start Cygwin from your desktop or start menu
  • Right click on the middle of the Windows title bar and click “Options…”
  • Go to Mouse in the left menu, and uncheck “Copy on select”. This behavior will cause cygwin to copy highlighted text to your clipboard. When trying to paste something in Cygwin, this gets annoying as it’s very easy to accidentally select something, thus clearing your clipboard.
  • Go to Terminal in the left menu, and change the type to “xterm-256color”
  • Recommended: Change the cursor color to yellow or something else very visible (Looks > Colours > Cursor).
  • Recommended: Change the cursor to an underscore (Looks > Cursor > Underscore). Makes it easier to spot.

Windows Drives

Cygwin uses a Linux style directory structure, so if you’d like to access your C drive or similar, it’s mounted under /cygwin/c. Please note, if your file or directory name has spaces in it, you’ll have to wrap the entire file path in quotes or use backslashes to escape the space, e.g.:

/cygdrive/c/Program\ Files\ \(x86\)/Git/bin/git.exe

or

"/cygdrive/c/Program Files (x86)/Git/bin/git.exe"

Where’s the executable?

If you don’t have a shortcut for Cygwin, you may be confused about how to start it. A cursory look around the installation directory won’t include any obvious cygwin.exe files or the like.

That’s because Cygwin isn’t a terminal, its a Linux API layer. The terminal is MinTTY, which you can start manually from the bin directory of your cygwin installation. It’ll be called mintty.exe. Mine is located at D:\Cygwin\bin\mintty.exe.

The Next Level

Once you’re setup with Cygwin, I recommend adding Tmux to the mix. It adds tabs & multi-pane support to MinTTY, and will significantly improve the way you work!

One Reply to “Getting Started With Cygwin”

  1. Thanks for writing this up. I’ve been using cygwin on my w10 machine to ssh into my centos server, so I basically could be using puTTY instead. So I’m scouring the web for suggestions on how to get more out of it. I’m going to set up tmux next.

    One note: ncurses is now under the Base category.

Leave a Reply